← Back to AILP Home

if / else

Syntax

if requires parentheses around the condition:

if (x > 0) {
    println("positive");
} else if (x == 0) {
    println("zero");
} else {
    println("negative");
}

Rules

Common Patterns

// Guard clause
if (input == NIL) {
    fail 1;
}

// With logical operators
if (age >= 18 && has_id) {
    println("Allowed");
}