In this program, we will create an integer range using the (..) operator, and will print the first element of the list using ".first", last element of the list using ".last", and the value of the step using ".step".
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:
need an explanation for this answer? contact us directly to get an explanation for this answer