cloning arrays

ag0aep6g via Digitalmars-d-learn digitalmars-d-learn at puremagic.com
Mon Sep 12 00:31:22 PDT 2016


On 09/12/2016 08:56 AM, Russel Winder via Digitalmars-d-learn wrote:
> Which raises the question of whether:
>
> 	x[]
>
> and
>
> 	x.dup
>
> have the same result.
>

No. x[] is a nop for dynamic arrays. Only the array struct (pointer and 
length) gets copied, as it always does. x.dup copies the array's 
elements to a new location.


More information about the Digitalmars-d-learn mailing list