Array of pointers
Andrej Mitrovic
andrej.mitrovich at gmail.com
Mon Jan 20 01:58:49 PST 2014
On 1/16/14, Philippe Sigaud <philippe.sigaud at gmail.com> wrote:
> The thing is, an array is a reference type
Actually it's not, let's not confuse people with the terminology here.
To recap for people new to arrays: an array in D is really just a
struct, e.g.:
struct Array
{
int* data;
size_t length;
}
Array myArray;
Once you know this it's easy to understand why passing myArray by
value to a function allows you to change the contents of "data", but
changing what "data" points to or changing the length of the array
will not be reflected at the call site, *unless* you've passed myArray
to a function by reference.
More information about the Digitalmars-d-learn
mailing list