NouvaLang v0.1.0
GitHub

If / Else Conditionals

Learn how to write clean, parentheses-free conditional branching with if, else if, and else blocks.


1. Basic if Statement

In NouvaLang, condition expressions do not require parentheses around them, but braces {} around the execution block are mandatory:

let score: int = 85;

if score >= 50 {
    print("Exam Passed");
}

2. if / else Branching

let age: int = 16;

if age >= 18 {
    print("Eligible to vote");
} else {
    print("Not eligible to vote");
}

3. Multiple Branches with else if

let grade: int = 92;

if grade >= 90 {
    print("Grade: A");
} else if grade >= 80 {
    print("Grade: B");
} else if grade >= 70 {
    print("Grade: C");
} else {
    print("Grade: F");
}
Truthiness Rules

In conditional checks: - Non-zero numbers (1, -5, 3.14) evaluate to true.
- Zero (0, 0.0) evaluates to false.
- Non-empty strings evaluate to true; empty strings ("") evaluate to false.
- null evaluates to false.