I currently use this code to directly return an object from a function if it is found in an array:
already_existing = my_array.find { |v| ... predicate ... }
return already_existing if already_existing
# ...
# Remaining of the function should be executed if object not found
Is there an elegant way to transform that into a one-liner?
Note: Without calling find twice of course, or calling include? first then find because it would have a performance hit)