New vs length on dymamic array

Vladimirs Nordholm v at vladde.net
Mon Nov 9 11:50:54 UTC 2020


On Monday, 9 November 2020 at 09:05:58 UTC, Imperatorn wrote:
> On Monday, 9 November 2020 at 08:06:54 UTC, Andrey wrote:
>> Hello,
>>
>> Are here any differences in creation of dynamic array with 
>> known size?
>>
>>> auto array = new wchar[](111);
>>
>> and
>>
>>> wchar[] array;
>>> array.length = 111;
>
> You can check using compiler explorer:
> https://godbolt.org/

I don't understand assembly, so this does not tell me anything 
useful.

Are there any reasons to prefer one over the other? I assume this 
is what OP is actually asking about.


More information about the Digitalmars-d-learn mailing list