Kotlin Ranges step() function


Example

Is it possible to iterate over numbers with arbitrary step, not equal to 1? Sure, the step() function will help you

for (i in 1..4 step 2) print(i) // prints "13"
for (i in 4 downTo 1 step 2) print(i) // prints "42"