select()
public
Returns a new hash consisting of entries which the block
returns true.
h = { "a" => 100, "b" => 200, "c" => 300 }
h.select {|k,v| k > "a"}
h.select {|k,v| v < 200}
Show source
VALUE
rb_hash_select(VALUE hash)
{
VALUE result;
RETURN_ENUMERATOR(hash, 0, 0);
result = rb_hash_new();
rb_hash_foreach(hash, select_i, result);
return result;
}