Kotlin Ranges downTo() function


Example

if you want to iterate over numbers in reverse order? It's simple. You can use the downTo() function defined in the standard library

for (i in 4 downTo 1) print(i) // prints "4321"