kotlin find index of item compare string code example
Example 1: how to get index of item in arraylist in kotlin
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 }
Example 2: kotlin element at index in string
val hello = "Hello World"
// Using get() function
val W = hello.get(6)
// Using indexing
val e = hello[1]