Is [ 0, 1, 2 ] an immutable array?

Ali Cehreli acehreli at yahoo.com
Tue Aug 11 16:05:56 PDT 2009


Does the expression [ 0, 1, 2 ] form an immutable array? If so, is the assignment to a[0] undefined below? Is it trying to modify an immutable element?

    int[] a = [ 0, 1, 2 ];
    a[0] = 42;

The reason for my thinking that [ 0, 1, 2] is an array is because it has the .dup property and this works too:

    int[] a = [ 0, 1, 2 ].dup;

Thank you,
Ali



More information about the Digitalmars-d-learn mailing list