rangeTo

Creates a range from this Comparable value to the specified that value.

operator fun <T : Comparable<T>> T.rangeTo(that: T): ClosedRange<T>(source)
fun main() {
    val range = 1.rangeTo(10)   // creates a ClosedRange<Int> from 1 to 10
    for (i in range) {
        println(i)
    }
}

Source