Function Array.opSliceAssign
Slicing assignment.
Array . Range opSliceAssign(size_t R)
(
T[R] value,
size_t i,
size_t j
) @trusted;
Array . Range opSliceAssign(R)
(
auto ref R value,
size_t i,
size_t j
) @trusted;
Array . Range opSliceAssign
(
Array . Range value,
size_t i,
size_t j
) @trusted;
Parameters
Name | Description |
---|---|
R | Type of the assigned slice or length of the static array should be assigned. |
value | New value (single value, range or static array). |
i | Slice start. |
j | Slice end. |
Returns
Slice with the assigned part of the array.
Precondition
i <= j && j <= length
&& value.length == j - i
Example
auto v1 = Array!int([3, 3, 3]);
auto v2 = Array!int([1, 2]);
v1[0 .. 2] = 286;
assert(v1[0] == 286);
assert(v1[1] == 286);
assert(v1[2] == 3);
v2[0 .. $] = v1[1 .. 3];
assert(v2[0] == 286);
assert(v2[1] == 3);
v1[0 .. 2] = [5, 8];
assert(v1[0] == 5);
assert(v1[1] == 8);
assert(v1[2] == 3);