If we want to exclude the last element of the range, we can use the until function:
val execRange1 = 1.until(10)
println(execRange1)
The until function can be declared as follows:
val execRange2 = 1 until 10
println(execRange2)
When demonstrating a range of character types in Declaring a range section, we created a complete alphabet using two dots. We can also do this using the to operator:
val alphabets2 = 'A' to 'Z'
println(alphabets2)
Another way to do this is by using ASCII code. 65 is the ASCII code for a capital A, while 90 is the ASCII code for a capital Z:
val alphabets3 = 'A'.until(91.toChar())
println(alphabets3)
Both ranges will display the same result—a complete alphabet in capital letters.