OCLOperators indexOf

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

This page was edited 63 days ago on 10/02/2024. What links here