Control Flow
If-Else Statements
Section titled “If-Else Statements”Ternary Operator
Section titled “Ternary Operator”cond ? then : else is the expression form of if/else — it produces a value,
so you can use it inline in an assignment, a function argument, or a return.
Only the chosen branch is evaluated (lazy), so a side effect in the untaken
branch never fires.
It binds looser than every other operator (including && / ||), so
a + b > 4 ? x : y parses as ((a + b) > 4) ? x : y, and
a ? b : c ? d : e parses as a ? b : (c ? d : e).
While Loop
Section titled “While Loop”For Loop
Section titled “For Loop”Tulpar supports both C-style for loops and for-each loops:
Match Expressions
Section titled “Match Expressions”match is a Rust-style pattern match. Unlike a C switch, it is an
expression — it produces a value, so you can assign it directly. Each arm
is pattern => body; _ is the catch-all wildcard. Arms support single
literals, |-alternatives, and inclusive lo .. hi ranges.
Patterns can match a set of values or a range. The subject is evaluated once, and the first matching arm wins:
match also works in statement position with block arms, and the subject may
be any expression (int, string, or bool):