【发布时间】:2011-01-15 17:44:34
【问题描述】:
我有一个哈希数组,@fathers。
a_father = { "father" => "Bob", "age" => 40 }
@fathers << a_father
a_father = { "father" => "David", "age" => 32 }
@fathers << a_father
a_father = { "father" => "Batman", "age" => 50 }
@fathers << a_father
如何搜索这个数组并返回一个块返回 true 的哈希数组?
例如:
@fathers.some_method("age" > 35) #=> array containing the hashes of bob and batman
谢谢。
【问题讨论】:
-
这个问题很有帮助,但我一直想知道为什么需要一组@fathers :P