aboutsummaryrefslogtreecommitdiff
path: root/exercises/042_pointers4.zig
diff options
context:
space:
mode:
authorDave Gauer <dave@ratfactor.com>2022-07-31 15:57:20 -0400
committerDave Gauer <dave@ratfactor.com>2022-07-31 15:58:24 -0400
commitb8617bb7527d39874b507a4c25bdaa8b6c4f4c3f (patch)
tree13bcaa129e879d2d97e71f48cc061642a3cfef4a /exercises/042_pointers4.zig
parent0e64778f3c27a4b42cc94f12c8c7029daed1bd8a (diff)
downloadziglings-b8617bb7527d39874b507a4c25bdaa8b6c4f4c3f.tar.gz
ziglings-b8617bb7527d39874b507a4c25bdaa8b6c4f4c3f.tar.bz2
ziglings-b8617bb7527d39874b507a4c25bdaa8b6c4f4c3f.tar.xz
ziglings-b8617bb7527d39874b507a4c25bdaa8b6c4f4c3f.zip
Correct conventional Zig reference vs value passing re #89
Diffstat (limited to 'exercises/042_pointers4.zig')
-rw-r--r--exercises/042_pointers4.zig11
1 files changed, 10 insertions, 1 deletions
diff --git a/exercises/042_pointers4.zig b/exercises/042_pointers4.zig
index 261dbc1..359a2f1 100644
--- a/exercises/042_pointers4.zig
+++ b/exercises/042_pointers4.zig
@@ -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");