I am really not convinced by the NPE problems argu...
# announcements
a
I am really not convinced by the NPE problems argument. 1. I have rarely if ever had a Java program blow up due to NPE. 2. Kotlin's protection from NPE ends whenever you use platform types. Those are not solved satisfactorily IMO.
Copy code
var res = someJavaFuncThatActuallyReturnsNull()
// res is now SomeJavaType!
// at this point I can start passing 'res' around and later access anything on it and get an NPE, Kotlin didnt help at all
57 replies It would be nice if Kotlin warned you when when assigning platform types to non-null properties. Like for example:
Copy code
class ExampleActivity : Activity {
    lateinit var array: IntArray

    override fun onCreate(savedInstanceState: Bundle?) {
        super.onCreate(savedInstanceState)
        array = intent.getIntArrayExtra("array")
        // throws IllegalStateException: getIntArrayExtra("array") must not be null
    }
}