0Pricing
Zig Academy · Lesson

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

  1. Compile-Time vs Run-Time
  2. comptime Parameters and Values
  3. Types Are comptime Values
  4. inline for and Unrolled Loops
← Back to Zig Academy