A
Alexander Presber
Hello everybody,
Could you please take a look at the result of the following statements:
irb(main):001:0> a = {'foo' => 'bar', 'baz' => 'qux'}
=> {"baz"=>"qux", "foo"=>"bar"}
irb(main):002:0> a.reject{|k,v| k=='foo' }
=> {"baz"=>"qux"}
irb(main):003:0> a.select{|k,v| k=='baz' }
=> [["baz", "qux"]]
The result of the reject statement is clearly sensible: the original
hash minus the element with the key 'foo'.
But what about select? Shouldn't it return the same hash (instead of
an array of key-value pairs)?
Thanks for any comments
Sincerely yours
Alexander Presber
Could you please take a look at the result of the following statements:
irb(main):001:0> a = {'foo' => 'bar', 'baz' => 'qux'}
=> {"baz"=>"qux", "foo"=>"bar"}
irb(main):002:0> a.reject{|k,v| k=='foo' }
=> {"baz"=>"qux"}
irb(main):003:0> a.select{|k,v| k=='baz' }
=> [["baz", "qux"]]
The result of the reject statement is clearly sensible: the original
hash minus the element with the key 'foo'.
But what about select? Shouldn't it return the same hash (instead of
an array of key-value pairs)?
Thanks for any comments
Sincerely yours
Alexander Presber