Skip to content

If-Else Statement

If-else statement is a conditional control-flow statement that allows skipping code. Supports simple if, if-else and if-else ladder.

Syntax
if (condition)
    statement1

if (condition)
    statement1
else
    statement2

if (condition1)
    statement1
else if (condition2)
    statement2
else
    statement3
Example
# prints "Hello World"
if (true) print("Hello World");

if (false) print("Hello World");
else print("Goodbye World");

text := "";
if (true) {
    text = "Hello World";
} else {
    text = "Goodbye World";
}

# prints "Hello World"
print(text);