Skip to content

Latest commit

 

History

History
28 lines (19 loc) · 562 Bytes

UnreachableCode.md

File metadata and controls

28 lines (19 loc) · 562 Bytes

Pattern: Unreachable code

Issue: -

Description

Code can be unreachable because it is behind return, throw, continue or break expressions. This unreachable code should be removed as it serves no purpose.

Example of incorrect code:

for (i in 1..2) {
    break
    println() // unreachable
}

throw IllegalArgumentException()
println() // unreachable

fun f() {
    return
    println() // unreachable
}

Further Reading