Modernizing Iteration Practices
Learn to optimize loops and leverage modern techniques for efficient coding.
Explicit index iteration
Developers with experience in older languages often use a for
loop where slightly more modern alternatives should be used instead.
Press + to interact
fun main() {val names = listOf("Alex", "Bob", "Celina")for (i in 0 until names.size) {val name = names[i]println("[$i] $name")}}// [0] Alex// [1] Bob// [2] Celina
...