Array.opIndexOpAssign

Assign to the element at idx in the array the result of a[idx] op elem. idx must be less than length.

struct Array(T)
ref
opIndexOpAssign
(
string op
U
)
(,
size_t idx
)
if (
isImplicitlyConvertible!(U, T)
)

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] == 5);
(a[2] += 3)++;
assert(a[2] == 9);

Meta