I have an array of hashes:
arr = [{"id"=>"1", "name"=>"Alan"}, {"id"=>"2", "name"=>"Ben"}, {"id"=>"3", "name"=>"Carl"}, {"id"=>"4", "name"=>"Danny"}, {"id"=>"5", "name"=>"Eva"}] If I were to find the name of id #4:
arr.find{ |a| a["id"] == "4" }["name"] returns "Danny", which is what I want.
My question is, is there a shorter, more elegant way of accomplish the same search?