Array.opIndexUnary

Apply an unary operation to the element at idx in the array. idx must be less than length.

struct Array(T)
ref
opIndexUnary
(
string op
)
(
size_t idx
)

Parameters

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]);
int x = --a[2];
assert(a[2] == 2);
assert(x == 2);

Meta