https://kotlinlang.org logo
#getting-started
Title
# getting-started
k

Klitos Kyriacou

10/04/2022, 2:02 PM
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

ephemient

10/04/2022, 2:24 PM
in general unreachable code is a warning, not an error, in Kotlin (different from Java)
👍🏾 1
👍 3
🙏 2