Skip to content
Course map | Lesson 1 of 5

Functions · 2.1

Basic Functions

All lessons are open — jump whenever you need.

Functions are declared with fn:

fn greet(name: str) -> str {
    return "Hello, {name}!"
}

print(greet("Alice"))

The return type is indicated with ->. The last value in a function can also be returned implicitly.

Goal: Create a function square that returns the square of a number and print square(7).

lesson-2-1.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