array initialization problem

Rainer Deyke rainerd at eldwood.com
Mon Jan 19 13:23:13 PST 2009


Denis Koroskin wrote:
> Arrays in D are reference types. Besides, it's best to avoid hidden
> allocations.

Arrays in D are reference types except when they're not.

int[] a = [5];
int[] b = a;
a[0] = 4;
assert(b[0] == 4);
a.length = 2;
assert(b.length == 1);
a[0] = 3;
// Is b[0] 3 or 4?


-- 
Rainer Deyke - rainerd at eldwood.com


More information about the Digitalmars-d-learn mailing list