adam.opIndex

adam opIndex(size_t index) ref @safe

Access an array element by index, returning a mutable reference.

Throws

AdamTypeException if the value is not an ARRAY;

AdamIndexException if index is out of range.

const(adam) opIndex(size_t index) ref const @safe

Const array element access by index.

Throws

AdamTypeException if the value is not an ARRAY;

AdamIndexException if index is out of range.

adam opIndex(string key) ref @safe

Access a map entry by key, returning a mutable reference.

Autovivification: this is an inserting accessor. Reading a missing key inserts adam.init (NULL) under it, and a NULL this is promoted to an empty OBJECT. This enables chained deep access like root["a"]["b"]["c"] = 1;, but it also means any read of a misspelled key silently creates that entry and returns NULL. For lookup without insertion use contains, get, or the const overloads (which throw AdamKeyException on missing keys instead).

const(adam) opIndex(string key) ref const @safe

Const member lookup by key (never inserts).

Throws

AdamTypeException if the value is not an OBJECT;

AdamKeyException if key is not present.