my_hash = { "foo1" => 666, "foo2" => "the number of the beast",
"name" => "Satan"}
Ahora, para obtener las llaves "foo1" y "foo2" utilizamos la función grep del modulo Enumerable:
my_hash.keys.grep /foo/
#["foo1", "foo2"]
Para obtener los valores, de cada entrada de forma rapida:
my_hash.keys.grep(/foo/).each{|f| puts my_hash[f]}#666
#the number of the beast
1 comments:
Pc games free
gta 4 free download
Post a Comment