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

indexOf0 ( object : T ) : Integer[edit | edit source]

Returns the position of object in the sequence self - 0-based.

Expression Result
Sequence{'a', 'b'}->indexOf0('a') 0

The zero-based index of an object in the collection can be -1 if it is nonexistent.

See the discussion and reason for the introduction of the IndexOf0 operator on the page for the IndexOf operator

See also at0

Example

Given a Class Car:

Car.allInstances->asSequence().Name->indexOf0('Toyota')

This will return the position of 'Toyota' in the collection.