what does array.reverse really does?

BCS BCS_member at pathlink.com
Fri Mar 31 13:02:15 PST 2006


In article <e0jrkd$2ou$1 at digitaldaemon.com>, Deewiant says...

>For another, to get rid of the first array element, I suggest "a = a[1..$]",
>which I would expect to be faster.
>


watch out for this though



int[] a = [1, 2, ..stuff...]
int[] b = a;

b = b[1..$];

assert(b[0] == a[0]);  //fails because only where b points to is changed.



somthing like this is needed to change the contents



foreach(int i, int j; a[1..$])
b[i] = j;






More information about the Digitalmars-d-learn mailing list