Range Operators
.. and until.
What Is a Range
A range represents a sequence of values between a start and an end.
Kotlin makes ranges first-class with the .. and until operators.
The .. Operator
The .. operator builds an inclusive range. Both ends are part of the range.
1..5 contains 1, 2, 3, 4, and 5.
fun main() {
val range = 1..5
println(range.toList())
}All lessons in this course
- Range Operators
- Step and downTo
- Ranges in Loops
- Char and Custom Ranges