In Smalltalk, you can “cascade” side-effectful calls to the same object using the semicolon (;) operator. E.g.:[gist id=”1238072″]
If I understand it correctly, the semicolon is effectively a K-combinator or “Kestrel”.
I am jealous. Sure, we have Object#tap, but that’s awfully verbose by comparison:[gist id=”1238083″]
(I’m using multiple taps in order to exactly mimic the semantics of the Smalltalk semicolon operator in the example above.)
Let’s see if we can do better for this simple case of cascading a series of commands, while ignoring their return values.[gist id=”1238090″ bump=1]
Yay! That looks a lot nicer.