Skip to content

Files

Latest commit

 

History

History
24 lines (17 loc) · 551 Bytes

LoopWithTooManyJumpStatements.md

File metadata and controls

24 lines (17 loc) · 551 Bytes

Pattern: Loop with too many jump statements

Issue: -

Description

Loops which contain multiple break or continue statements are hard to read and understand. To increase readability they should be refactored into simpler loops.

Example of incorrect code:

val strs = listOf("foo, bar")
for (str in strs) {
    if (str == "bar") {
        break
    } else {
        continue
    }
}

Further Reading