| Section | Title |
|---|---|
| 1 | Blocks are Expressions |
| 2 | if Expressions |
| 3 | switch Expressions |
| 4 | while Loops |
| 5 | for Loops |
| 6 | break, continue, and Labels |
| 7 | defer |
| 8 | Exercises |
Blocks are ExpressionsA block is a sequence of statements inside braces.
`if` ExpressionsIn Zig, if is an expression. It can produce a value.
`switch` ExpressionsA switch chooses one branch from several alternatives.
`while` LoopsA while loop repeats while a condition is true.
`for` LoopsA for loop visits the elements of an array, slice, or range.
`break`, `continue`, and Labelsbreak leaves a loop.
`defer`defer runs a statement when control leaves the current block.
ExercisesThis section collects the exercises for the chapter. They are meant to be small programs. Each one should compile and run.