🚀 Welcome to MDriven Learn –  Don’t miss the latest Release Notes.
OCLOperators at0

at0 ( index : Integer ) : T

Returns the element of self at the *index* position.

Note! This is a 0-based index.

Expression Result
Sequence{'a', 'b'}->at0(1) b

It returns the element in the collection using zero-based indexing. This means at0(0) returns the first element, at0(1) returns the second, and so on. It is especially useful when working with Sequences or when converting your instance collections into sequences using asSequence() or similar operators.

Example:

Department.allInstances->at0(0)

Results:


See also the at operator and comments on indexof operators