typeover
curriculum

Curriculum Memory ArrayList exercise 3 · mcq

ArrayList

TypeScript reads .length to get a list's size and indexes with [i]. Zig's ArrayList exposes the live elements via the .items slice — and you use .items.len for length, .items[i] for indexing. Pick the right access.

TypeScript reference
Pick the idiomatic Go translation

About this theme

ArrayList(T) is Zig's growable slice — your TypeScript Array equivalent. In Zig 0.16 it's an unmanaged container by API convention: you initialize with the .empty literal, pass the allocator on every mutating call (append, insert, etc.), and call .deinit(allocator) to release. items is a []T view into the live elements; the capacity is hidden. The benefit of unmanaged: no per-list allocator pointer overhead, and the list type is a plain struct you can store in a hash map's value.