comptime Parameters and Values
Pass values that exist at compile time.
Some Arguments Must Be Known Early
Sometimes a function needs an argument the compiler can see, not just the running program. Zig lets you mark such a parameter comptime. 🧩
Marking a comptime Parameter
Write comptime before a parameter name to require that its value be known at compile-time. The caller must pass a known value.
fn repeat(comptime n: usize) void {}All lessons in this course
- Compile-Time vs Run-Time
- comptime Parameters and Values
- Types Are comptime Values
- inline for and Unrolled Loops