我有一个哈希数组,@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
我该如何搜索此数组,并返回其中满足条件的哈希数组?
比如:
@fathers.some_method("age" > 35) #=> array containing the hashes of bob and batman
谢谢。
@fathers
哈希里的每个元素都有一个 'father' 键而不是一个 'name' 键。我希望我能相信这些是父亲的父亲,但我不能。 - cesoid