#'use' + pipe operator
1 messages · Page 1 of 1 (latest)
That's right, you've not supplied all the arguments to bool.guard there
use doesn't have a special case where it behaves differently for pipe, so what you're doing doesn't work
I thought it would be the same as use <- bool.guard(condition, "OK")
From the compiler POV that's extra work to figure out
bool.guard(condition, "OK") is a call expr
condition |> bool.guard("OK") is a pipeline expr
use always does either:
- Inserts the function as the final argument if it's a call
- Turns it into a call if it isn't and then does 1.
There is no special case for pipe and there never will be.
they're similar but not the same
ok, I understand, thank you for your answers
In general I'd avoid doing that because it's difficult to read, even if it worked
That's our motivation for not adding a special case there
From my (novice) POV bool.guard(condition, "OK") and condition |> bool.guard("OK") are both the same function (currying) asking one parameter
There's no technical limitation, it's a language design matter