Language Guide / Control Flow & Match

Control Flow & Match

Branching with if/else, while and for ... in loops, break/continue, and match.

Conditionals (if / else if / else)

Conditions must evaluate to a strict bool (true or false).

branch.dl
score = 88
if score >= 90
    show "A"
else if score >= 80
    show "B"
else
    show "C"
end

Loops (while and for ... in)

Iterate over lists, ranges (range(start, stop)), or repeat while a condition holds. break and continue work in both loop forms.

loops.dl
for i in range(0, 5)
    if i == 2
        continue
    end
    show i
end

n = 3
while n > 0
    show n
    n = n - 1
end

Pattern Matching (match)

Use match to dispatch cleanly on discrete values:

match.dl
status = 200
match status
    200 -> show "OK"
    404 -> show "Not Found"
    _   -> show "Other"
end