0Pricing
Zig Academy · Lesson

null Versus undefined

Two different kinds of absence.

Two Words, Two Meanings

Zig has both null and undefined, and they are not the same. Mixing them up is a classic source of confusing bugs.

null Means No Value

null is a real, defined state: it says this optional intentionally holds nothing. It is a meaningful, checkable value.

const x: ?i32 = null;

All lessons in this course

  1. Declaring Optional Types
  2. Unwrap Safely with if and orelse
  3. Optional Pointers and ?*T
  4. null Versus undefined
← Back to Zig Academy