typeover
curriculum

Curriculum Types Arrays vs slices exercise 5 · fill-word

Arrays vs slices

Fill the missing two-character operator that builds a slice of an array's full range. Used as arr[start..end] — leave both ends off to slice the whole thing.

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.