Docs > Control Flow

For loops use for-in format: ``` for x in y { ... } ``` Here, in `...`, `x` would be bound to the next item in `y`. You can also omit the name, and it will be bound to `_`: ``` for y { ... } ``` Here we could access `_` in `...`. While loops function as normal: ``` while e { ... } ``` Here `...` will be run until `e` is false. We don't have to pass a block to any of these constructs: ``` while e ... ``` This will work whenever `...` is a single expression. `if` also functions as normal: ``` if a { ... } else { ... } ``` Once again, both `...`s can be changed to single expressions instead of blocks. Note that the `else` is optional. All control flow constructs are expressions. `while` and `for` evaluate to the last expression evaluated in their bodies; `if` evaluates to whatever condition was true. For example, `if true 5 else 6` evaluates to `5`, but `if false 5 else 6` evaluates to `6`. Thus, `if` can be used as a ternary. Because `if` is an expression, we can use `else if` for multiple conditions: ``` if a { ... } else if b { ... } else { ... } ```