3 ms·
> "Expressions Math.sqrt(64) and 64 |> Math.sqrt are equivalent. The difference is in how we read it. With pipeline operator data flows from left to the right,
by gedy 8y ago
> "Expressions Math.sqrt(64) and 64 |> Math.sqrt are equivalent. The difference is in how we read it. With pipeline operator data flows from left to the right, and thus making it much more comprehensible"
Ugh, no, that's a very subjective statement,
64 |> Math.sqrt is not "much more comprehensible" assuming especially for beginners.
- williamdclt 8y agoI agree that this example isn't convincing, I also prefer the "vanilla" Math.sqrt(64). It's more convincing (IMO) when chaining calls, eg: Math.sqrt(Math.ceil(Math.sin(64))) VS. 64 |> Math.sin |> Math.ceil |> Math.sqrt
- mercer 8y agoI used to feel that way until I got comfortable with Elixir and its pipe operator. I think without prior knowledge the latter, which is interpreted left-to-right, is more intuitive: "take some data, do x, do y, do z"