How to get the index in a for each loop? I want to print numbers for every second iteration
For example
for (value in collection) { if (iteration_no %
Alternatively, you can use the withIndex library function:
for ((index, value) in array.withIndex()) { println("the element at $index is $value") }
Control Flow: if, when, for, while: https://kotlinlang.org/docs/reference/control-flow.html