2 ms·
More discussion about this idiom, this time discussing Ruby 1.9's #tap method: http://blog.rubybestpractices.com/posts/gregory/011-tap-that-hash.html http://bl
by raganwald 17y ago
More discussion about this idiom, this time discussing Ruby 1.9's #tap method:
http://blog.rubybestpractices.com/posts/gregory/011-tap-that-hash.html http://blog.rubybestpractices.com/posts/gregory/011-tap-that...
- luigi 17y agoAny insight as to why they chose to name it tap instead of returning? I much prefer returning.
- raganwald 17y agoThe original use cae was where you have a method chain and you want to "tap into" one of the values, e.g. foo().bar().blitz() becomes: foo().bar().tap { |b| puts b.inspect }.blitz() It takes its inspiration from Unix's "tee."