Skip to content
Course map | Lesson 3 of 5

Functions · 2.3

Pipe Operator |>

All lessons are open — jump whenever you need.

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

Global index

Find your way through Zolo

Try an idea

Start here

9 results

9 results

enespt-br