Skip to content

Instantly share code, notes, and snippets.

@AMHOL
Created July 11, 2013 08:20
Show Gist options
  • Save AMHOL/5973551 to your computer and use it in GitHub Desktop.
Save AMHOL/5973551 to your computer and use it in GitHub Desktop.
Try chain in Ruby
class Object
def try_chain(*a)
a.inject(self){ |object, method| object.try(method.to_sym) }
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment