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