Curriculum Types Arrays vs slices exercise 2 · mcq
Arrays vs slices
When you don't want to repeat the length, use _ as the
array length and let the compiler count from the initializer.
Pick the right declaration.
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.