0PricingLogin
Zig Academy · Lesson

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

  1. Fixed-Size Arrays
  2. Slices: A Pointer Plus a Length
  3. Slicing with array[start..end]
  4. Iterating and Mutating Slices
← Back to Zig Academy