I was reading through the Ruby 2.5.0 release blurb, referred from Ben Halpern's article here, and I saw that one of the new features is the #yield_...
For further actions, you may consider blocking this person and/or reporting abuse
I love
yield_self&tap, thanks for the article!Btw you can get a similar effect pre-2.5 with
to_enum(:tap).That converts
tapinto anEnumeratorobject, which allows you to chain it with other methods without having to pass a block totap.Neat! Thanks for the tip!
Great article! I've used this several times when I forgot about
yield_self. Thanks very much for providing some simple use cases.I also wanted to point out a typo in the line:
.yield_self(&:shout), it should not contain the:. It should look like this to work:.yield_self(&shout). It got me confused why it didn't work for a while :)Thanks! I fixed it. I appreciate the heads up!