I used #grep method with Range,Array.

a = ['foo','fish','bar']
a.grep(/f/) # => ["foo", "fish"]
(1..40).grep (6..9) # => [6, 7, 8, 9]

But never with Hash. So today I tired something like below :

h = { "arup" => 100, "banti" => 200, "carry" => 300, "Pood" => 300 }
h.grep(/a/i) # => []

Intention was to collect all key/value which has key, that match a
pattern /a/i. But it didn't worked. With Hash, probably #grep not worked
that way.

Any one can tell me how to use `#grep` with a `Enumerable` like `Hash` ?

-- 
Posted via http://www.ruby-forum.com/.