...

/

Range and Control Statements

Range and Control Statements

Learn to utilize ranges along with break and continue statements for streamlined and optimized looping.

We'll cover the following...

Range

In Kotlin, if we place two dots between two numbers, like 1..5, we create an IntRange. This class implements Iterable<Int>, so we can use it in a for loop:

Press + to interact
fun main() {
for (i in 1..5) {
print(i)
}
}
// 12345

This solution is efficient as ...