I have an array of hashes, each of which has two attributes: title and Zscore. I want to return either the result of find or the last element. This can be done with:a = array.select{|i| i[title] == some title}b = a.find{|i| i[Zscore].to_f >= 5} || a.lastIs there an elegant way to put the conditional inside the block, something like the following?array.select{|i| i[title] == some title}.find{|i| i[Zscore].to_f >= 5 || last}Any built-in method? Any ideas of one-liner that is nicer than the following?array.select{|i| i[title] == some title}.find{|i| i[Zscore].to_f >= 5} ||array.select{|i| i[title] == some title}.last
Ruby array search, returning either a result with a good score or the last result
ruby;array;search