Skip to content

Instantly share code, notes, and snippets.

@arturictus
Last active July 1, 2016 13:31
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save arturictus/79fff28b4a69d27d056a532b98881da3 to your computer and use it in GitHub Desktop.
Save arturictus/79fff28b4a69d27d056a532b98881da3 to your computer and use it in GitHub Desktop.
class Array
# find_map
# example:
# [nil, 'hello '].find_map |n|
# n.try(:strip)
# end => 'hello'
def find_map(&block)
result = nil
self.each do |q|
result = yield(q)
break if result
end
result
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment