06 Conditional execution
An if/else statement chooses which block of work to run.
norm
main() {
Integer score = 82
if score >= 90 {
printLine("excellent")
} else if score >= 60 {
printLine("passed")
} else {
printLine("try again")
}
}Output:
text
passedConditions must have type Boolean. Branches are checked in order; the first true branch runs and the others are skipped. This lesson uses if for actions. A later lesson uses if itself as a value.
Try it: Set score to 95, then 40, and identify which branch runs each time.
Precise rules: Language Reference.