indexOfFirst

Returns index of the first element matching the given predicate, or -1 if the sequence does not contain such element.

inline fun <T> Sequence<T>.indexOfFirst(predicate: (T) -> Boolean): Int(source)
fun main() {
    val fruits = sequenceOf("apple", "banana", "cherry", "date")

    // Find the index of the first fruit that starts with 'c'
    val index = fruits.indexOfFirst { it.startsWith('c') }

    println(index)   // Output: 2
}

Source