0PricingLogin
Zig Academy · Lesson

var for Mutable State

When and how to allow reassignment.

When Values Change

Some values truly need to move: a counter, a running total, a current score. For those, Zig gives you the var keyword.

Meet var

The keyword var creates a mutable binding. Unlike const, the name you declare with var can be reassigned again and again.

var score = 0;

All lessons in this course

  1. const for Values That Never Change
  2. var for Mutable State
  3. Type Inference vs Explicit Types
  4. undefined and Uninitialized Memory
← Back to Zig Academy