Created
February 8, 2011 21:55
-
-
Save rbxbx/817345 to your computer and use it in GitHub Desktop.
eeevil
This file contains 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 Object | |
def try_chain *meths | |
meths.inject(self) do |res, meth| | |
break unless result = res.try(meth) | |
result | |
end | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment