← Back to Docs
if / elif / else
Conditional branching with if, elif, and else.
Syntax
if (condition) {
// runs if condition is true
} elif (condition2) {
// runs if condition2 is true
} else {
// runs if nothing above matched
}Simple if
let x = 10;
if (x > 5) {
print("x is big");
}if / else
let age = 15;
if (age >= 18) {
print("adult");
} else {
print("minor");
}if / elif / else
let score = 85;
if (score >= 90) {
print("A");
} elif (score >= 80) {
print("B");
} elif (score >= 70) {
print("C");
} else {
print("F");
}Multiple elif
You can chain as many elif blocks as needed.
Truthiness
Conditions are evaluated for truthiness:
| Type | Truthy | Falsy |
|---|---|---|
| Integer | Any non-zero | 0 |
| String | Non-empty | "" |
| Bool | true | false |
| Void | — | Always falsy |