Array.opOpAssign

Append the elements of rhs at the end of the array.

If no allocator was provided when the list was created, the GCAllocator.std.experimental.allocator.gc_allocator. will be used.

struct Array(T)
ref
opOpAssign
(
string op
U
)
(
auto ref U rhs
)
if (
op == "~" &&
(
is(U == typeof(this)) ||
is(U : T)
||
(
isInputRange!U &&
isImplicitlyConvertible!(ElementType!U, T)
)
)
)

Parameters

rhs U

can be an element that is implicitly convertible to T, an input range of such elements, or another Array

Return Value

Type: auto ref

a reference to this array

Complexity: O(n + m), where m is the number of elements in rhs.

Examples

import std.algorithm.comparison : equal;

Array!int a;
auto a2 = Array!int(4, 5);
assert(a.empty);

a ~= 1;
a ~= [2, 3];
assert(equal(a, [1, 2, 3]));

// append an input range
a ~= a2;
assert(equal(a, [1, 2, 3, 4, 5]));
a2.front = 0;
assert(equal(a, [1, 2, 3, 4, 5]));

Meta