Passing parameters by value or reference
When passing parameters to a function, there are actually two different ways in which these parameters can arrive at the body of that function – by value or reference. We, as programmers, do not choose which of the two is used; GDScript makes this decision based on the data type of the value we provide the function. Let’s take a deeper look into both the methods for passing values, which data types apply to each, and why it is important to know the difference.
Passing by value
Passing by value means that GDScript sends over an exact copy of a value to a function. This approach is very simple and predictable because we get a new variable in the function that we called. However, because copying over data takes time, it can be quite slow for big data types.
Data types that get passed by value are any of the simpler built-in data types, such as integers, floating point numbers, and Booleans. Some also slightly more complex...