x |> f(a) means f(x, a): each step after |> is a function name or path, with optional
arguments. Mixing a .method() into the same chain, or piping into a closure, is rejected.
Wrong#
fn total(xs: [int]): int = xs |> map(x => x * 2).sum()Fixed#
fn total(xs: [int]): int = xs |> map(x => x * 2) |> sum()Common causes#
- Mixing
|>and.in one chain: use one style throughout, or wrap the pipe in parentheses. - Piping into a closure
xs |> (x => ...): call a named function instead. - A literal or expression after
|>.