Values & References10 / 18
Up next

Slices are fat pointers

const std = @import("std");

pub fn main() void {
    const arr = [_]i32{ 10, 20, 30 };
    const s: []const i32 = &arr;
    // a slice carries both .ptr and .len
    std.debug.print("len {d} first {d}\n", .{ s.len, s.ptr[0] });
}
What you're solving

a slice bundles a pointer and length