Fundamentals14 / 15
Up next

Loop with an index

fun main() {
    val letters = listOf("a", "b", "c")
    // destructure each (index, value) pair
    for ((i, c) in letters.withIndex()) {
        println("$i: $c")
    }
}
What you're solving

withIndex pairs position with item