我有这个哈希数组:
results = [
{"day"=>"2012-08-15", "name"=>"John", "calls"=>"5"},
{"day"=>"2012-08-15", "name"=>"Bill", "calls"=>"8"},
{"day"=>"2012-08-16", "name"=>"Bill", "calls"=>"11"},
]
我如何搜索结果以找到比尔在 15 日打了多少电话?
在阅读“ Ruby easy search for key-value pair in an hashes array ”的答案后,我认为它可能涉及扩展以下 find 语句:
results.find { |h| h['day'] == '2012-08-15' }['calls']