Curriculum Collections Arrays vs slices exercise 5 · fill-word
Arrays vs slices
Translate ${name}.push(${value}) to idiomatic Go. The built-in
is a free-standing function — not a method on the slice — and
it RETURNS a new slice header that you must assign back.
TypeScript reference
Fill the blanks →
About this theme
Go has fixed-size arrays ([N]T) and dynamically-sized slices ([]T). You almost always want slices. A slice is a view over a backing array — three machine words: pointer, length, capacity. append grows it; make pre-sizes it. The mental model is closer to Rust's Vec than to TS's Array.