3 ms·
In a language like Ruby and most imperative mutable ones pipelines could be a nice syntactic sugar for constructs like this a = f1() a = f2(a) a = f3(a,
by pmontra 7y ago
In a language like Ruby and most imperative mutable ones pipelines could be a nice syntactic sugar for constructs like this
a = f1()
a = f2(a)
a = f3(a, b)
a = f4(a, c)
It becomes (let me use Unix pipes)
a = f1()
| f2()
| f3(b)
| f4(c)
OO idiomatically handles that by making each method return an object with the status and at least the next method to be called
a = f1().f2().f3(b).f4(c)
However unless the class of that object is something standard and already available like (example) Ruby's Enum, it's a pain to code it (and understand it later on) and people go for the shortcut of writing the code at the beginning of my reply.