Since my previous article about Ruby 2.5 new
#yield_self method I started to use it a lot—in production and experimental code.
Here, I just want to share several code samples/ideas of usage, where this seemingly simple method allows to rewrite code in— let’s say another way. Which somebody may consider cleaner, more functional, or better showing the intention.
After considering and comparing a lot of possibilities in experimental code, and after using
yield_self extensively in production, I now firmly believe that the best possible name for the method is just
.then. Despite being a keyword, it is allowed by current syntax to be a method and reads extremely clear in…