Skip to content
← Index | Lesson 1 of 5

if/else as expression

if/else in Zolo

if/else is an expression in Zolo — it returns a value:

let x = 10
let msg = if x > 5 { "big" } else { "small" }
print(msg) // big

Goal: Write a function sign(n) that returns "positive", "negative" or "zero". Test with 5, -3 and 0.

lesson-3-1.zolo
Program output

Run the code to see the output

Search Zolo

9 results

enespt-br