Skip to content

Instantly share code, notes, and snippets.

@rjungemann
Created December 26, 2009 05:54
Show Gist options
  • Save rjungemann/263851 to your computer and use it in GitHub Desktop.
Save rjungemann/263851 to your computer and use it in GitHub Desktop.
Enable Object#tap in Ruby 1.8
# Object.tap method for Ruby 1.8 as defined at
# http://ciaranm.wordpress.com/2008/11/30/recursive-lambdas-in-ruby-using-objecttap/
if not Object.respond_to? :tap
class Object
def tap
yield self
self
end
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment