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
- Function Syntax and Return Types
- Passing Values vs References
- pub Functions and Visibility
- Recursion and Multiple Returns