hamstergem / hamster

Efficient, Immutable, Thread-Safe Collection classes for Ruby
Other
1.89k stars 94 forks source link

Hamster::Hash#values_at doesn't fill up nils for missing keys #215

Closed dubek closed 8 years ago

dubek commented 8 years ago

Pure Ruby:

{:a => 1}.values_at(:a, :b, :c)
 => [1, nil, nil]

Hamster:

Hamster::Hash[:a => 1].values_at(:a, :b, :c)
 => Hamster::Vector[1] 

This is also explicitly stated in the Hamster::Hash#values_at rdoc:

    # Return a {Vector} of the values which correspond to the `wanted` keys.
    # If any of the `wanted` keys are not present in this `Hash`, they will be skipped.

Need to consider where to fix this, this is a bug (in terms of parity with Ruby) but this fix is a change in Hamster behaviour which requires a major ver? IDK.

alexdowad commented 8 years ago

Good catch. This is definitely a bug; a bug in specification.

I would prefer just to bump the minor version number after applying a fix. @krainboltgreene?

krainboltgreene commented 8 years ago

:+1:

On Fri, Dec 4, 2015 at 8:08 PM, Alex Dowad notifications@github.com wrote:

Good catch. This is definitely a bug; a bug in specification.

I would prefer just to bump the minor version number after applying a fix. @krainboltgreene https://github.com/krainboltgreene?

— Reply to this email directly or view it on GitHub https://github.com/hamstergem/hamster/issues/215#issuecomment-162137494.

Kurtis Rainbolt-Greene, Hacker Software Developer 1631 8th St. New Orleans, LA 70115

dubek commented 8 years ago

Fixed in ae7e0b24c5dea0b0bfecb2d867f65b3e4bef7d36 with better specs.