Is it possible to continue n times in a kotlin loop?
for(i in 0..n){
doSomething()
if(condition){
//manipulate n
}
}
Since i
for some reason is a val I cannot seem to reinitialize it in the loop.
How labeled continue works? Label in Kotlin starts with an identifier which is followed by @ . Here, outerloop@ is a label marked at outer while loop. Now, by using continue with the label ( continue@outerloop in this case), you can skip the execution of codes of the specific loop for that iteration.
repeat(n){
blah()
}
Will execute blah()
n
times.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With