From b8617bb7527d39874b507a4c25bdaa8b6c4f4c3f Mon Sep 17 00:00:00 2001 From: Dave Gauer Date: Sun, 31 Jul 2022 15:57:20 -0400 Subject: Correct conventional Zig reference vs value passing re #89 --- exercises/042_pointers4.zig | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) (limited to 'exercises/042_pointers4.zig') 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"); -- cgit v1.2.3-ZIG