0Pricing
Kotlin Academy · Lesson

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

  1. Range Operators
  2. Step and downTo
  3. Ranges in Loops
  4. Char and Custom Ranges
← Back to Kotlin Academy