OCLOperators indexOf
This page was created by Alexandra on 2017-08-13. Last edited by Edgar on 2025-01-20.

indexOf ( object : T ) : Integer

Returns the position of object in sequence self.

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

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

(note that probably the specification says that this should be 1-based and not 0-based as it is. This makes it a confusing to use the at(int)-operator that IS 1 based.

We have introduced a IndexOf0:int that explicitly is zero based to better sit with the explicit zero based at0(int))

We recommend you use IndexOf0 and at0 operators over IndexOf and at

MDriven Chat

How would you like to chat today?

Setting up your conversation…

This may take a few moments