Skip to content

Commit

Permalink
docs(general): Sample code errors - Pass by Value and Pass by Reference
Browse files Browse the repository at this point in the history
YoYoGames/GameMaker-Bugs#9226

Fixed incorrect variable names passed to the functions in the code sample
  • Loading branch information
YYBartT committed Jan 31, 2025
1 parent 4e3fac6 commit b6e521b
Showing 1 changed file with 2 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -80,11 +80,11 @@ <h2 id="pass_by_value_and_pass_by_reference">Pass by Value and Pass by Reference
}<br />
<br />
var _val_orig = 48593;<br />
try_to_modify_value(_val, 75);<br />
try_to_modify_value(_val_orig, 75);<br />
show_debug_message(_val_orig);<br />
<br />
var _array_orig = [1, 2, 3];<br />
try_to_modify_array(_array, 100);<br />
try_to_modify_array(_array_orig, 100);<br />
show_debug_message(_array_orig);
</p>
<p>In the call to <span class="inline3_func">try_to_modify_value()</span>, the value stored in <span class="inline2">_val_orig</span> is assigned to the function parameter <span class="inline2">_value</span>. Since this value is 48593, i.e. of type <span data-keyref="Type_Real"><a href="Data_Types.htm" target="_blank">Real</a></span>, it is copied. The new value 75 is assigned to <span class="inline2">_value</span>, which goes &quot;out of scope&quot; after the function finishes. <span class="inline2">_val_orig</span> isn&#39;t changed at all and still holds the value 48593.</p>
Expand Down

0 comments on commit b6e521b

Please sign in to comment.