const for Values That Never Change
Immutable bindings by default.
Bindings Start Here
In Zig, you give a value a name with a binding. The first choice you make is whether that name is allowed to change later.
Meet const
The keyword const creates a name whose value can never be reassigned. It is the safe, default way to name things in Zig.
const pi = 3.14159;All lessons in this course
- const for Values That Never Change
- var for Mutable State
- Type Inference vs Explicit Types
- undefined and Uninitialized Memory