Thread
#stdlib
    gabrielfv

    gabrielfv

    3 years ago
    Is there a reason for there not being a findIndexed()/firstOrNullIndexed() method for the
    Iterable
    class, which takes a
    (T) -> Boolean
    predicate and returns
    IndexedValue<T>
    ?
    orangy

    orangy

    3 years ago
    .indexOfFirst {  }
    gabrielfv

    gabrielfv

    3 years ago
    Depends on adding
    .takeIf { it >= 0 }?.let { Pair(it, list[it]) }
    . Works, though
    ilya.gorbunov

    ilya.gorbunov

    3 years ago
    If you need an
    IndexedValue
    in the end, you can try
    .withIndex().find { predicate(it.value) }