Kotlin Loops in Kotlin While Loops


Example

While and do-while loops work like they do in other languages:

while(condition) {
    doSomething()
}

do {
    doSomething()
} while (condition)

In the do-while loop, the condition block has access to values and variables declared in the loop body.