티스토리 뷰

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

'공부' 카테고리의 다른 글

[kotlin] swagger  (0) 2023.11.03
[macosx] iterm cursor move  (1) 2023.11.03
[Spring] @Value  (0) 2023.11.03
[Spring] Query String 파싱, @RequestParam  (0) 2023.11.03
[Spring] security http antMatcher with multiple paths  (0) 2023.11.03
댓글