Array.opIndexAssign

Assign elem to the element at idx in the array. idx must be less than length.

  1. auto ref opIndexAssign(U elem, size_t idx)
    struct Array(T)
    ref
    opIndexAssign
    (
    U
    )
    (,
    size_t idx
    )
    if (
    isImplicitlyConvertible!(U, T)
    )
  2. auto ref opIndexAssign(U elem)

Parameters

elem U

an element that is implicitly convertible to T

idx size_t

a positive integer

Complexity: O(1).

Return Value

Type: auto ref

a reference to the element found at idx.

Examples

auto a = Array!int([1, 2, 3]);
a[2] = 2;
assert(a[2] == 2);
(a[2] = 3)++;
assert(a[2] == 4);

Meta