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?
Some languages provide pipeline operators or alike for use with imperative functions/methods:
dotothat 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)..apply(with receiver) and.also(with argument) are available as extension methods on objects (see Kotlin scope functions)..- or|>-like tap operator.)This operation is also known as “tap” or “tee”. Is this a useful addition to Rhombus?