typeover
curriculum

Curriculum Types Arrays vs slices exercise 4 · fill-word

Arrays vs slices

Fill the missing single character that tells the compiler to infer the array length from the initializer. Used inside the square brackets of the type — same character used in TS for "don't care" or "discard."

TypeScript reference
Fill the blanks →

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.