Skip to content

Instantly share code, notes, and snippets.

@mikekreeki
Created January 15, 2013 18:29
Show Gist options
  • Save mikekreeki/4540794 to your computer and use it in GitHub Desktop.
Save mikekreeki/4540794 to your computer and use it in GitHub Desktop.
Smarter Object#tap
class Object
alias :old_tap :tap
def tap(&block)
old_tap do
if block.arity == 0
instance_eval &block
else
block.(self)
end
end
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment