inline for and Unrolled Loops
Iterate at compile time.
A Loop That Runs at Compile-Time
An inline for is a loop the compiler unrolls during compilation. Instead of looping at run-time, it copies the body for each item. 🔁
The inline Keyword
Put inline in front of for to ask Zig to expand the loop at compile-time. The iteration count must be known then.
inline for (items) |item| {}All lessons in this course
- Compile-Time vs Run-Time
- comptime Parameters and Values
- Types Are comptime Values
- inline for and Unrolled Loops