Go theorytheory 0/50 · 0%
Collections · easy

7. Arrays, Slices and Append

Slices are views with length and capacity.

Arrays have a fixed length that is part of their type; slices are the everyday type, holding a pointer, length and capacity. `append` may reallocate when capacity is exceeded, so always reassign the result. Slicing shares the underlying array, so copies may be needed to avoid aliasing.

Check your understanding

  1. 1. What must you do with append's result?

  2. 2. Two slices from the same array…