Last active
July 1, 2016 13:31
-
-
Save arturictus/79fff28b4a69d27d056a532b98881da3 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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