0PricingLogin
Zig Academy · Lesson

Passing Values vs References

How arguments reach your function.

How Arguments Travel

When you call a function, Zig must get your data inside it. There are two routes: pass the value itself or pass a reference to it. 🚚

Passing by Value Copies

By default, primitive arguments are passed by value: the function gets its own copy and cannot change your original.

fn addOne(n: i32) i32 {
    return n + 1;
}

All lessons in this course

  1. Function Syntax and Return Types
  2. Passing Values vs References
  3. pub Functions and Visibility
  4. Recursion and Multiple Returns
← Back to Zig Academy