key.var.opIndex
var opIndex(string key) ref @safeAccess a child value by key, turning this instance into a map on first use.
Semantics:
- If this value is currently
Type.NULL, it is converted to a map (Type.OBJECT). - If this value is not a map after that (i.e., it was a scalar or array), a
VarTypeExceptionis thrown. - Returns a reference to the stored child
var, inserting a defaultvar.initif missing.Returns
A reference to the value stored at
const(var) opIndex(string key) ref const @safeConst overload of opIndex for read-only map access.
Unlike the mutable overload, this does not convert Type.NULL to a map, and does not insert missing keys. It throws a VarTypeException if the value is not a map, or a VarKeyException if the key is not present.
Returns
A const reference to the value stored at
key.var opIndex(size_t index) ref @safeIndex into the array payload and return a reference to the element.
In coercion mode, out-of-range indices grow the array with var.init fill; otherwise a VarIndexException is thrown for out-of-range access.
Preconditions:
- The current value must be
Type.ARRAY(orNULL, which is converted). indexmust be in range[0 .. length), otherwise aVarIndexExceptionis thrown (non-coercion mode).
const(var) opIndex(size_t index) ref const @safeConst overload of opIndex for read-only array access.
Returns
A const reference to the element at
index.