Created
December 26, 2009 05:54
-
-
Save rjungemann/263851 to your computer and use it in GitHub Desktop.
Enable Object#tap in Ruby 1.8
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
# 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