How to allocate arrays of objects?
Jacob Carlborg via Digitalmars-d-learn
digitalmars-d-learn at puremagic.com
Thu Feb 11 01:02:30 PST 2016
On 2016-02-11 05:34, Adam D. Ruppe wrote:
> On Thursday, 11 February 2016 at 04:31:12 UTC, cy wrote:
>> as[0..$] = new A();
>>
>> before accessing .stuff on as[0].
>
> Loop through it and allocate each one rather than trying to do it in a
> one liner like that.
What about this?
as[] = new A();
Or will that allocate a new one for each element?
--
/Jacob Carlborg
More information about the Digitalmars-d-learn
mailing list