mirror of
https://codeberg.org/ziglings/exercises.git
synced 2026-06-08 07:50:00 +00:00
Correct conventional Zig reference vs value passing re #89
This commit is contained in:
@@ -1,6 +1,15 @@
|
||||
//
|
||||
// Now let's use pointers to do something we haven't been
|
||||
// able to do before: pass a value by reference to a function!
|
||||
// able to do before: pass a value by reference to a function.
|
||||
//
|
||||
// Why would we wish to pass a pointer to an integer variable
|
||||
// rather than the integer value itself? Because then we are
|
||||
// allowed to *change* the value of the variable!
|
||||
//
|
||||
// +-----------------------------------------------+
|
||||
// | Pass by reference when you want to change the |
|
||||
// | pointed-to value. Otherwise, pass the value. |
|
||||
// +-----------------------------------------------+
|
||||
//
|
||||
const std = @import("std");
|
||||
|
||||
|
||||
Reference in New Issue
Block a user