Skip to content

Pipe Operator

Chain function calls left-to-right with |>:

wyn
fn double(x: int) -> int { return x * 2 }
fn add1(x: int) -> int { return x + 1 }
fn square(x: int) -> int { return x * x }

var result = 3 |> add1 |> double |> square
println(result.to_string())    // 64

The pipe passes the left-hand value as the first argument to the right-hand function.

Step by Step

3 |> add1       = add1(3)       = 4
4 |> double     = double(4)     = 8
8 |> square     = square(8)     = 64

Try It

🐉 Playground
Press Run or Ctrl+Enter

MIT License