3 ms·
Because that's not how the pipe operator works in any other language.
by ezekg 4y ago
Because that's not how the pipe operator works in any other language.
- askonomm 4y agoIn Clojure it does: (-> "Hello, World" string/uppercase (string/split #",") first string/trim) `->` is a threading-first macro, and `->>` is a threading last macro. More here: https://clojure.org/guides/threading_macros https://clojure.org/guides/threading_macros
- eyelidlessness 4y agoBeat me to it while I was typing! Alas, I’m on mobile and your example is a better illustration of the point.
- eyelidlessness 4y agoOf course it is, at least conceptually. See various lisps’ threading macros (which are of course functions over code; but they correspond exactly to mapping over a series of functions, each one supplying input to the next).
- ezekg 4y agoI totally agree, I shouldn't have been so absolute in my statement. But JS is not a lisp. The |> foo bar baz syntax doesn't jive with any other syntax in JS, but foo |> bar |> baz does.
- capableweb 4y agoAs someone else, it does in Clojure (which is what I wrote most of the time). But even if it didnt, does it matter? If there is a better way, the way is better, no matter if it exists in other languages or not. If all languages tried to be the same, most of them would be boring.