Curriculum Types Pointers exercise 1 · mcq
Pointers
TypeScript has no separate pointer syntax — passing an object
to a function passes a reference, end of story. Zig is
explicit. Pick the type for a parameter that's a single
pointer to an i32 so the function can mutate the caller's
variable.
About this theme
TypeScript has no pointer syntax — everything is a reference under the hood. Zig has dedicated syntax for pointers, and several flavours: *T (single pointer to one T), *const T (read-only single pointer), and — surfaced later in the curriculum — [*]T (many-item pointer, length unknown) and ?*T (nullable single pointer). This theme focuses on the two-flavour core (*T + *const T) since those are the shapes you write every day; many-item and nullable pointers come up in Module 3 (memory) and Module 4 (errors) respectively when their natural use cases arrive. &value takes the address; p.* dereferences. The discipline: pick the narrowest flavour that fits the use case.