Check out example codes for "how to get index of item in arraylist in kotlin". It will help you in understanding the concepts better.

Code Example 1

val b: List<Int> = a.mapIndexed { i, b -> if (b) i else null }.filterNotNull().toList()
val c: List<Int> = a.withIndex().filter { it.value }.map { it.index }

Learn ReactJs, React Native from akashmittal.com