Node.opIndexAssign

void opIndexAssign(K, V)(V value, K index)

Set element at specified index in a collection.

This method can only be called on collection nodes.

If the node is a sequence, index must be integral.

If the node is a mapping, sets the _value corresponding to the first key matching index (including conversion, so e.g. "42" matches 42).

If the node is a mapping and no key matches index, a new key-value pair is added to the mapping. In sequences the index must be in range. This ensures behavior siilar to D arrays and associative arrays.

To set element at a null index, use YAMLNull for index.

Parameters

valueValue to assign.
indexIndex of the value to set.

Throws

NodeException if the node is not a collection, index is out

of range or if a non-integral index is used on a sequence node.