VariantN.opIndex

Array and associative array operations. If a VariantN contains an (associative) array, it can be indexed into. Otherwise, an exception is thrown.

  1. inout(Variant) opIndex(K i)
    struct VariantN(size_t maxDataSize, AllowedTypesParam...)
    inout
    inout(Variant)
    opIndex
    (
    K
    )
    (
    K i
    )
  2. Variant opIndexAssign(T value, N i)
  3. Variant opIndexOpAssign(T value, N i)

Examples

Variant a = new int[10];
a[5] = 42;
assert(a[5] == 42);
a[5] += 8;
assert(a[5] == 50);

int[int] hash = [ 42:24 ];
a = hash;
assert(a[42] == 24);
a[42] /= 2;
assert(a[42] == 12);

Meta

Suggestion Box / Bug Report