Values & References6 / 18
Up next

Pass by pointer

const std = @import("std");

// taking *i32 lets us change the caller's variable
fn double(n: *i32) void {
    n.* *= 2;
}

pub fn main() void {
    var x: i32 = 5;
    double(&x);
    std.debug.print("{d}\n", .{x});
}
What you're solving

*T lets a callee mutate the caller