[] (lookup) operator

The lookup operator accesses a particular item in a Correspondence.


void m(Integer[] seq) {
    Integer? first = seq[0];

Note that first is Integer? rather than Integer because of the possibility that seq doesn't have a value for the given key.


The lookup operator gets an item from a Correspondence according to its key.

Since Ceylon 1.2.2 the lookup operator also works with Java java.util::List and java.util::Map and Java array types.

Some Correspondence types also satisfy the CorrespondenceMutator interface and can be mutated with the lookup assign operator.


The [] operator is defined as follows:


See the language specification for more details.


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


The result type of the lhs[index] operator is the element type of the Correspondence lhs.

See also