indexOf

fun <T> Array<out T>.indexOf(element: T): Int(source)
fun ByteArray.indexOf(element: Byte): Int(source)
fun IntArray.indexOf(element: Int): Int(source)
fun LongArray.indexOf(element: Long): Int(source)
fun CharArray.indexOf(element: Char): Int(source)

Returns first index of element, or -1 if the array does not contain element.

Since Kotlin

1.0

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

Returns first index of element, or -1 if the collection does not contain element.

Since Kotlin

1.0

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

Returns first index of element, or -1 if the list does not contain element.

Since Kotlin

1.0

Returns first index of element, or -1 if the array does not contain element.

Since Kotlin

1.3

Deprecated

Warning since 1.4

Error since 1.6

The function has unclear behavior when searching for NaN or zero values and will be removed soon. Use 'indexOfFirst { it == element }' instead to continue using this behavior, or '.asList().indexOf(element: T)' to get the same search behavior as in a list.

Replace with

indexOfFirst { it == element }

Returns first index of element, or -1 if the array does not contain element.

Since Kotlin

1.0