Why does Kotlin allow the following? ``` try { ...
# getting-started
k
Why does Kotlin allow the following?
Copy code
try {
        foo()
    } catch (e: Exception) {
        //...
    } catch (e: RuntimeException) {
        //...
    }
The Java compiler rejects it because it knows that RuntimeException will never be caught as it appears after Exception. The Kotlin equivalent doesn't even trigger a warning in the IDE. Does the Kotlin plugin for IntelliJ IDEA have at least an option to turn on a warning for this?
👀 2
e
in general unreachable code is a warning, not an error, in Kotlin (different from Java)
👍🏾 1
👍 3
🙏 2