indexOf

fun <T> Iterable<T>.indexOf(element: T): Int(source)

Returns the index of the first equal element, or -1 when no element matches.

Indexes follow iteration order and start at zero. Equality uses element == value. Stops at the first match. Exceptions from iteration propagate to the caller.

Receiver

elements to visit in their iteration order.

Return

the matching index, or -1 when empty or unmatched.

Parameters

element

value to search for, including null for nullable element types.

Throws

if a visited element index would exceed Int.MAX_VALUE.