Creating 1000 instances

Ferhat Kurtulmuş aferust at gmail.com
Fri Feb 19 11:33:57 UTC 2021


On Friday, 19 February 2021 at 10:02:05 UTC, Siemargl wrote:
> On Friday, 19 February 2021 at 08:29:36 UTC, Ferhat Kurtulmuş 
> wrote:
>
>> Since classes are reference types all instances of files will 
>> be the same reference of "new File()", which you probably 
>> don't want.
>
> Is any differences between x and y definitions?
>
> MyClass [] x, y;
> x = new MyClass[7];
>
> y= new MyClass[](8);

Although I don't usually use the latter, I can say online d 
editor yields the same ASM output for both:

File[] files = new File[10];
File[] files = new File[](10);


More information about the Digitalmars-d-learn mailing list