Ranges in Loops
Iterate cleanly.
Ranges Power Loops
Ranges and progressions are the natural way to drive for loops in Kotlin.
There is no classic C-style for(i=0; i<n; i++); you iterate over a range instead.
Basic Counting Loop
Loop over an inclusive range to count from a start to an end.
The variable takes each value in turn.
fun main() {
for (i in 1..5) {
print(i.toString() + " ")
}
println()
}All lessons in this course
- Range Operators
- Step and downTo
- Ranges in Loops
- Char and Custom Ranges