[]= (lookup assign) operator

The lookup assign operator assigns a particular item in a CorrespondenceMutator. It is the mutation variant of the lookup operator.


void m(Array<Integer> array) {
    array[0] = 2;


The lookup assign operator assigns an item in a CorrespondenceMutator to a given key.

The lookup assign operator also works with Java java.util::List and java.util::Map and Java array types.

Most CorrespondenceMutator types also satisfy the Correspondence interface and can be accessed with the lookup operator.


The []= operator is defined as follows:

// For IndexedCorrespondenceMutator
lhs.set(index, item)
// For KeyedCorrespondenceMutator
lhs.put(key, item)

See the language specification for more details.


The []= operator is polymorphic. The meaning of []= depends on the CorrespondenceMutator interface.


The result type of the lhs[key] = item operator is item value.

See also