0PricingLogin
Zig Academy · Lesson

Slices: A Pointer Plus a Length

Reference a window into an array.

Why Slices Exist

Arrays carry a fixed length, but functions often need to work with any length. A slice solves this by describing a flexible run of elements. 🔪

Two Pieces of Data

A slice is really just two things bundled together: a pointer to the first element and a length counting how many follow.

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