Note: information on this page refers to Ceylon 1.0, not to the current release.

[] (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.

Definition

The [] operator is defined as follows:

lhs.item(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