[]=
(lookup assign) operator
The lookup assign operator assigns a particular item in a CorrespondenceMutator
. It
is the mutation variant of the lookup operator.
Usage
void m(Array<Integer> array) {
array[0] = 2;
}
Description
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.
Definition
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.
Polymorphism
The []=
operator is polymorphic.
The meaning of []=
depends on the
CorrespondenceMutator
interface.
Type
The result type of the lhs[key] = item
operator is item
value.
See also
- API documentation for
CorrespondenceMutator
- The lookup operator
- sequence operators in the language specification
- operator precedence in the language specification
- Operator polymorphism in the Tour of Ceylon