我有一系列哈希,@ 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
Run Code Online (Sandbox Code Playgroud)
如何搜索此数组并返回一个块返回true的哈希数组?
例如:
@fathers.some_method("age" > 35) #=> array containing the hashes of bob and batman
Run Code Online (Sandbox Code Playgroud)
谢谢.