Array.opSliceAssign

Slicing assignment.

  1. Range opSliceAssign(T[R] value, size_t i, size_t j)
  2. Range opSliceAssign(R value, size_t i, size_t j)
    struct Array(T)
    @trusted
    opSliceAssign
    (
    R : T
    )
    (
    auto ref R value
    ,
    size_t i
    ,
    size_t j
    )
  3. Range opSliceAssign(Range value, size_t i, size_t j)

Parameters

R

Type of the assigned slice or length of the static array should be assigned.

value R

New value (single value, range or static array).

i size_t

Slice start.

j size_t

Slice end.

Return Value

Type: Range

Slice with the assigned part of the array.

Precondition: i <= j && j <= length && value.length == j - i

Examples

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);

Meta