Slicing with array[start..end]
Carve sub-views without copying.
Carving Out a View
Sometimes you want only part of an array. Slicing lets you grab a sub-range as a new slice without copying any elements. ✂️
The Range Syntax
Write the start and end inside brackets joined by two dots: array[start..end]. This produces a slice over those positions.
const part = data[1..3];All lessons in this course
- Fixed-Size Arrays
- Slices: A Pointer Plus a Length
- Slicing with array[start..end]
- Iterating and Mutating Slices