Neither the two-dots operator nor the rangeTo function can create a range in reverse order. We cannot, for example, write 5.rangeTo1 or 5..1. We can, however, use the downTo function to create a range in reverse order:
val range1 = 10.downTo(1)
for(i in range1) {
println(i)
}
val range2 = 10 downTo 1
for(i in range2) {
println(i)
}
Both range1 and range2 consist of numbers from 10 to 1.