These are great examples! The "dependent actions" tap scenario is the one I internalized the easiest - if you're assigning a value to a variable only to take intermediate actions before returning it (like your example) it's a natural refactoring.
I was totally unaware of Object#then until now, and will think about how to use that, too.
Thank you for the feedback, Daniel. then is a recent discovery for me, too. Interestingly, it has been around since ruby 2.5 but with a different name - yield_self. Not long after, in ruby 2.6, the alias then was introduced. Apparently, yield_self was not a consensual name. I find this thread on the community discussing the method name really interesting.
For further actions, you may consider blocking this person and/or reporting abuse
We're a place where coders share, stay up-to-date and grow their careers.
These are great examples! The "dependent actions" tap scenario is the one I internalized the easiest - if you're assigning a value to a variable only to take intermediate actions before returning it (like your example) it's a natural refactoring.
I was totally unaware of
Object#then
until now, and will think about how to use that, too.Thank you for the feedback, Daniel.
then
is a recent discovery for me, too. Interestingly, it has been around since ruby 2.5 but with a different name -yield_self
. Not long after, in ruby 2.6, the aliasthen
was introduced. Apparently,yield_self
was not a consensual name. I find this thread on the community discussing the method name really interesting.