Array.dup

Perform a copy of the array. This will create a new array that will copy the elements of the current array. This will NOT call dup on the elements of the array, regardless if T defines it or not.

struct Array(T)
dup
(
this Q
)
()

Return Value

Type: Array!T

a new mutable array.

Complexity: O(n).

Examples

import std.algorithm.comparison : equal;

auto stuff = [1, 2, 3];
auto a = immutable Array!int(stuff);
auto aDup = a.dup;
assert(equal(aDup, stuff));
aDup.front = 0;
assert(aDup.front == 0);
assert(a.front == 1);

Meta