You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Some languages provide pipeline operators or alike for use with imperative functions/methods:
Clojure provides doto that works like ->, except that each forms are evaluated and discarded, and the original value is returned. For example, (doto (new java.util.HashMap) (.put "a" 1) (.put "b" 2)) initiates a Java mutable hash table (see the ClojureDocs page).
In Kotlin, .apply (with receiver) and .also (with argument) are available as extension methods on objects (see Kotlin scope functions).
(Unfortunately, I couldn’t find a precedent on a .- or |>-like tap operator.)
This operation is also known as “tap” or “tee”. Is this a useful addition to Rhombus?
For doto: I think it's more useful to have the underlying API return the mutable object instead of void, which means just regular pipelines work properly.
FWIW, I experimented early on with having methods of mutable objects return the object, and I found it noisy (because results tend to get printed) and less clear than having Void as a result to highlight imperative behavior.
Activity
samth commentedon Dec 15, 2025
For
doto: I think it's more useful to have the underlying API return the mutable object instead of void, which means just regular pipelines work properly.mflatt commentedon Dec 15, 2025
FWIW, I experimented early on with having methods of mutable objects return the object, and I found it noisy (because results tend to get printed) and less clear than having
Voidas a result to highlight imperative behavior.