T[new] misgivings
Sergey Gromov
snake.scaly at gmail.com
Sat Oct 17 18:05:54 PDT 2009
Thu, 15 Oct 2009 21:55:07 -0500, Andrei Alexandrescu wrote:
> int[new] a;
> ...
> a = [1, 2, 3];
>
> What should that do?
To me a is an array, a reference type. Therefore assignment here means
rebinding a to a new array created from a literal.
> A: Ok, then how do I say the common operation "I want to overwrite
> whatever the array had with 1, 2, 3"? I can only presume there must be
> an obvious and simple way to do so, and I thought a = [1, 2, 3] was the
> obvious syntax to achieve that.
I'd say
a.replace([1, 2, 3]);
> T[new] a;
> T[] b;
> ...
> a = b;
>
> What should that do?
Error: type mismatch. Use
a = b.dup;
More information about the Digitalmars-d
mailing list