Range Until in Kotlin

Level 245 keystrokes

Iterates over a range that excludes the end value, using until.

Kotlin code

// until builds a range that excludes the end: 0 until 5 is 0..4
// Handy for indexes of a collection of size 5
1for (i in 0 until 5) {
// Prints Index: 0 through Index: 4
2 println("Index: $i")
3}

Output

Index: 0
Index: 1
Index: 2
Index: 3
Index: 4
Practice typing this code

Practice typing this code. Results are not recorded in the rankings.

Symbols in this code

The symbols you type in this Kotlin code and how often they appear.

  • "× 2
  • (× 2
  • )× 2
  • :× 1
  • {× 1
  • }× 1
  • $× 1

More Kotlin examples at level 2

← Kotlin typing practice