0PricingLogin
Zig Academy · Lesson

Optional Pointers and ?*T

Combine pointers with optionality.

Pointers Can Be Optional Too

A pointer normally must always aim at a valid value. Make it optional and it gains a legitimate way to mean nothing yet.

The ?*T Shape

The type ?*T reads as: an optional pointer to a T. It either points at a real value or holds null.

var node: ?*Node = 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