Curriculum Types Arrays vs slices exercise 3 · mcq
Arrays vs slices
To pass an array to a function that takes a slice, you build
a slice from it. The full-array shortcut is arr[0..] — slice
the whole thing. Pick the right call site.
TypeScript reference
About this theme
Zig has two collection shapes where TypeScript has one. [N]T is a fixed-length array; the length N is part of the type, known at compile time. []T is a slice: a pointer plus a runtime length. Pass an array to a function and you pass a copy; pass a slice (built via arr[0..]) and you pass a view. Module 3 builds on this.