Values & References9 / 18
Up next

Mutable slices

const std = @import("std");

// a []i32 slice can modify whatever array it views
fn zeroAll(s: []i32) void {
    for (s) |*e| e.* = 0;
}

pub fn main() void {
    var arr = [_]i32{ 1, 2, 3 };
    zeroAll(&arr);
    std.debug.print("{any}\n", .{arr});
}
What you're solving

[]T writes into the backing array