Hi,
i wonder if this is somehow planned to add such extension to Array and List like indexOfOrNull()
similar to already existing fun String.indexOfOrNull
Hi,
i wonder if this is somehow planned to add such extension to Array and List like indexOfOrNull()
similar to already existing fun String.indexOfOrNull
What?
Sorry i wasn’t precise. This fun String.indexOfOrNull
I’ve found here kotlin/addToStdlib.kt at master · JetBrains/kotlin · GitHub.
But main point is to discuss adding such extensions like
public fun <@kotlin.internal.OnlyInputTypes T> Array<out T>.indexOfOrNull(element: T): Int? =
indexOf(T).takeIf(it >= 0)
public fun <@kotlin.internal.OnlyInputTypes T> Iterable<T>.indexOfOrNull(element: T): Int? =
indexOf(T).takeIf(it >= 0)