loading...

re: Pros and Cons of Ruby's .tap Method VIEW POST

FULL DISCUSSION
 

One of my favorite uses for tap is in debugging method chains. I even have something for that in my .pryrc.

class Object
  def d
    tap { |o| p o }
  end
end

Then you can use it like this:

"foo".upcase.d.reverse
"FOO"
#=> "OOF"
code of conduct - report abuse