Skip to content

Instantly share code, notes, and snippets.

@evanphx
Created January 16, 2009 23:57
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 evanphx/48215 to your computer and use it in GitHub Desktop.
Save evanphx/48215 to your computer and use it in GitHub Desktop.
class TrySink
def initialize(obj)
@object = obj
end
undef class
def method_missing(meth, *a)
if @object.respond_to? meth
@object.__send__ meth, *a
else
nil
end
end
end
class Object
def try
TrySink.new(self)
end
end
a = []
p a.try.class
p a.try.crap
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment