typeover
curriculum

Curriculum Basics Optionals (?T) exercise 4 · fill-word

Optionals (?T)

Fill the missing keyword. The expression provides a fallback value when the left side is null. TypeScript's ?? operator, but as a keyword. Six letters, one word.

TypeScript reference
Fill the blanks →

About this theme

TypeScript uses T | null (or T | undefined) to mark "maybe absent" values; Zig's analogue is the type prefix ?T. A ?T value is either some T or null. Three idiomatic ways to handle one: orelse <default> (TS ??), if (x) |unwrapped| { ... } (payload capture that runs only when present), or x.? for "I know it's not null, unwrap anyway" (panics on null). No more silent nullable bugs.