Kotlin program of print the first, last, and step value of a range

bookmark

fun main(args: Array<String>) {    
    // print first element of the range
    println((1..10 step 2).first)

    // print first element of the range
    println((1..10 step 2).last)

    // print value of the step
    println((1..10 step 2).step)
}

 


Output:

1
9
2