arraydup

Makes a copy of the given array on newly allocated memory.

extern (D) pure nothrow
T[]
arraydup
(
T
)
(
const scope T[] s
)

Parameters

s
Type: T[]

array to copy

Return Value

Type: T[]

A copy of the input array.

Examples

1 auto s1 = [0, 1, 2];
2 auto s2 = s1.arraydup;
3 s2[0] = 4;
4 assert(s1 == [0, 1, 2]);
5 assert(s2 == [4, 1, 2]);
6 string sEmpty;
7 assert(sEmpty.arraydup is null);

Meta