[] (lookup) operator

The lookup operator accesses a particular item in a Correspondence.

Usage

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.

Description

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.

Definition

The [] operator is defined as follows:

lhs.get(index)

See the language specification for more details.

Polymorphism

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

Type

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

See also