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
- Declaring Optional Types
- Unwrap Safely with if and orelse
- Optional Pointers and ?*T
- null Versus undefined