Skip to content

Instantly share code, notes, and snippets.

@yuki24
Created October 11, 2012 15:01
Show Gist options
  • Save yuki24/3872990 to your computer and use it in GitHub Desktop.
Save yuki24/3872990 to your computer and use it in GitHub Desktop.
Better Object#tap
class Object
def tap(method = nil, *args, &block)
return super() if method.nil? && args.empty? && block_given?
public_send(method, *args)
self
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment