Language guide · 6 of 12

Control Flow

If / Else

Like Go, parentheses around conditions are optional, but { ... } blocks are strictly required:

if score >= 90 {
    grade = "A"
} else if score >= 80 {
    grade = "B"
} else {
    grade = "C"
}
Open in playground

While Loops

var x := 5
while x > 0 {
    io.println(x)
    x -= 1
}
Open in playground

For Loops (for ... in)

Evie features a unified for ... in loop supporting both single-element and indexed iteration across arrays, objects, strings, and buffers:

// 1. Array iteration
for item in ["apple", "banana", "cherry"] {
    io.println(item)
}

// 2. Array iteration with index
for i, item in ["apple", "banana", "cherry"] {
    io.println(i, item) // 0 apple, 1 banana, 2 cherry
}

// 3. Object key iteration
for key in { a: 1, b: 2 } {
    io.println(key)
}

// 4. Object key & value iteration
for key, val in { a: 10, b: 20 } {
    io.println(key, "=", val)
}

// 5. String iteration (characters)
for ch in "Evie" {
    io.println(ch)
}

// 6. Break and Continue
for n in [1, 2, 3, 4, 5] {
    if n == 2 {
        continue
    }
    if n == 4 {
        break
    }
    io.println(n)
}
Open in playground

Switch Statements

Evie supports multi-branch matching with switch:

// 1. Value Switch with comma-separated matching
switch day {
case "monday", "tuesday", "wednesday", "thursday", "friday":
    io.println("weekday")
case "saturday", "sunday":
    io.println("weekend")
default:
    io.println("invalid day")
}

// 2. Tagless Switch (evaluates boolean conditions)
switch {
case score >= 90:
    grade = "A"
case score >= 80:
    grade = "B"
default:
    grade = "F"
}

// 3. Early Break
switch mode {
case 1:
    setup()
    break // terminates switch branch
    unreachable()
}
Open in playground

Edit this page on GitHub