Skip to content
← Index | Lesson 3 of 5

Pipe Operator |>

Pipe Operator

The |> operator passes the result of the left expression as the first argument of the right function:

fn double(x: int) -> int { x * 2 }
fn add_one(x: int) -> int { x + 1 }

// Equivalent to add_one(double(5))
let result = 5 |> double() |> add_one()
print(result) // 11

Goal: Use pipe to calculate: (10 + 5) * 2 - 1 = 29. Implement the functions add_five, double and sub_one.

lesson-2-3.zolo
Program output

Run the code to see the output

Search Zolo

9 results

enespt-br