Created
March 7, 2023 03:31
-
-
Save ryanw-mobile/d6c0594734263697a45fc3825c81f4a4 to your computer and use it in GitHub Desktop.
Kotlin for-loop: forEachIndexed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
val bakes = listOf("sausage roll", "steak bake", "festive bake") | |
// Print each item in the list along with its index | |
bakes.forEachIndexed { index, bakeItem -> | |
println("$index: $bakeItem") | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment