Software Design/Transform data with pipeline operator
Examples[edit | edit source]
"The quick brown fox" |> String.upcase() |> String.split() # Result: ["THE", "QUICK", "BROWN", "FOX"]
Why[edit | edit source]
The written sequence of functions corresponds to how are applied one after another, which makes the code more natural to read.
Why not[edit | edit source]
There are many situations where the pipeline operator is not applicable: for example when the expression should be sent to a function with several parameters as a non-last parameter. Using several different function application forms can be seen as inconsistency: it's against the practice to always use the same way to do a thing.
Related[edit | edit source]
Sources[edit | edit source]
- David Thomas; Andrew Hunt (2019). The Pragmatic Programmer (20th Anniversary ed.). Addison-Wesley Professional. ISBN 978-0135957059.