Bug #15443
closed
Hash#slice
takes an array of keys via *keys
each parameter is checked as a key in the Hash
{ 1 => :a, 2 => :b, 3 => :c }.slice(2, 3) #=> { 2 => :b, 3 => :c }
{ 1 => :a, 2 => :b, 3 => :c }.slice([2, 3]) #=> {} [2,3] is not a key in Hash
There is no special Rule for Range, that's why you get {}
- Status changed from Open to Rejected
Not a bug but a spec of Hash#slice
. Consider the case where the keys are a range:
{ (1..) => :a, (2..) => :b, (3..) => :c }.slice(2..) #=> {2..=>:b}
Note that this behavior is not specific to endless range:
{ 1 => :a, 2 => :b, 3 => :c }.slice(2..3) #=> {}
It sound reasonable ;) this can be closed then
Also available in: Atom
PDF
Like0
Like0Like0Like0