Working on Android/Kotlin app, I'm having trouble finding indices of second and third element in the array that fulfills some condition. Since I know there are 4 elements in the array that would return true, i can use indexOfFirst() and indexOfLast(), but that way, I get only the first and the fourth indices.
val array: Array<String>
val firstOne = array.indexOfFirst(::func)
val lastOne = array.indexOfLast(::func)
fun func(element: String): Boolean{
return element=="a" }
I tried using filterIndexed() but that returns a new list, and only values are saved, but not indices of the elements in there, which I need