select

hsh.select {|key, value| block} â a_hash
hsh.select â an_enumerator
Instance Public methods

Returns a new hash consisting of entries for which the block returns true.

If no block is given, an enumerator is returned instead.

h = { "a" => 100, "b" => 200, "c" => 300 }
h.select {|k,v| k > "a"}  #=> {"b" => 200, "c" => 300}
h.select {|k,v| v < 200}  #=> {"a" => 100}
doc_ruby_on_rails
2015-04-12 00:42:19
Comments
Leave a Comment

Please login to continue.