Is this a bug?

Meta via Digitalmars-d-learn digitalmars-d-learn at puremagic.com
Tue Apr 29 10:01:44 PDT 2014


On Tuesday, 29 April 2014 at 16:52:27 UTC, Ali Çehreli wrote:
> That may be misleading because there is no need to allocate 
> with an explicit new. For example, the slice below is owned by 
> the GC as well:
>
> int[] foo()
> {
>     int[] a;
>     a ~= 42;    // on memory owned by the GC
>     return a;
> }

I didn't realize this was possible... I figured it was equivalent 
to
`null ~= 42` which I realize now is not correct, because a is not 
entirely a reference type. I'm not sure how I feel about this.



More information about the Digitalmars-d-learn mailing list