4 ms·
I think the clarity comes from the reading order. str |> method1 |> method2 |> method3 vs method3(method2(method1(str))).
by efdee 11y ago
I think the clarity comes from the reading order. str |> method1 |> method2 |> method3 vs method3(method2(method1(str))).
- mbreese 11y agoThat's readable in the simple case, (arg1 is a string, returns a string). What about the more complex cases? Different method signatures, required extra arguments, returning objects or arrays? This will either a) break in those cases, or b) not be applicable. In which case, it's extra complexity for very little gain. Seriously, this just seems like syntax sugar that just isn't needed. I get that you might not think it's elegant, but is anyone seriously troubled or confused by method3(method2(method1(str)))? How would the pipeline syntax help here?
- whichdan 11y agoYep; same reason Lodash implements _.flow and _.compose. It also encourages you to write methods that take a single argument and return a single value, or partially apply those that don't.