| Section | Title |
|---|---|
| 1 | if Expressions |
| 2 | switch |
| 3 | while Loops |
| 4 | for Loops |
| 5 | Labels and Block Expressions |
| 6 | break and continue |
| 7 | Inline Loops |
| 8 | Defer and Cleanup |
| 9 | Unreachable Code |
| 10 | Compile Errors as Safety Checks |
`if` ExpressionsPrograms need to make choices.
`switch`An if statement is good for general conditions:
`while` LoopsPrograms often need to repeat work.
`for` LoopsA while loop repeats while a condition is true.
Labels and Block ExpressionsZig has blocks.
`break` and `continue`Loops repeat code. But sometimes you do not want a loop to finish in the normal way.
Inline LoopsZig has normal loops that run when the program runs.
Defer and CleanupMany programs need to clean something up after using it.
Unreachable CodeSome parts of a program should never run.
Compile Errors as Safety ChecksA compile error means Zig refused to build your program.