lastIndexOf

open override fun lastIndexOf(element: E): Int(source)

Returns the index of the last occurrence of the specified element in the list, or -1 if the specified element is not contained in the list.

For lists containing more than Int.MAX_VALUE elements, a result of this function is unspecified.

Since Kotlin

1.4

Samples

import kotlin.math.*
import kotlin.test.*

fun main() { 
   //sampleStart 
   val list = listOf('a', 'b', 'c', 'a')
assertEquals(3, list.lastIndexOf('a'))
assertEquals(1, list.lastIndexOf('b'))
assertEquals(-1, list.lastIndexOf('e')) 
   //sampleEnd
}