공부
[kotlin] How can I break out of a Kotlin `repeat` loop?
승가비
2023. 11. 3. 15:47
728x90
run repeatBlock@ { // need to make a label outside of the repeat!
repeat(20) { idx ->
println(">> $idx")
if(idx >= 2)
return@repeatBlock
}
}
https://stackoverflow.com/questions/68277152/how-can-i-break-out-of-a-kotlin-repeat-loop
How can I break out of a Kotlin `repeat` loop?
How do I break out of a Kotlin repeat loop? (I see plenty of answers about forEach, but I want to see a repeat-specific answer.) You can't use a naked return, because that will return from what co...
stackoverflow.com
728x90