Dz
Djazair
v1.0.5
🔍

Loops

Perform repeated executions using while, do-while, and for-in constructs.

While Loop

Runs as long as a boolean expression evaluates to True:

let i = 1
while i <= 5
    print("Count: ${i}")
    i = i + 1
end

Do-While Loop

Executes the body block at least once, then continues while the condition matches:

let x = 10
do
    print("Runs at least once: ${x}")
    x--
while x > 5

For-In Iteration

Iterate over items in arrays, strings, ranges, or key-value entries in maps:

# Array iteration
for fruit in ["apple", "banana"]
    print(fruit)
end

# String iteration (character by character)
for char in "Hi"
    print(char)
end

# Range iteration (.. syntax)
for idx in 1..4
    print("Index: ${idx}")
end

# Range iteration (to syntax)
for i in 0 to 3
    print("i: ${i}")
end

# Map iteration (unpacking key, value)
let scores = {"Riad": 95, "Sarah": 99}
for name, score in scores
    print("${name} scored ${score}")
end

Break & Continue

Standard loop directives are fully supported: break immediately terminates the loop, while continue skips to the next iteration:

for i in 0..5
    if i == 3
        break  # stops at 3
    end
    if i == 1
        continue  # skips printing 1
    end
    print(i)
end
# Output: 0 2
© 2026 Harizi Riyadh. Released under the MIT License.
Official Website for Djazair.