https://kotlinlang.org logo
g

gregschlom

07/29/2016, 11:48 PM
If
foo
is nullable and we test that foo?.someMethod != null, why can't we infer that foo is non null? For example:
Copy code
fun test(foo: String?) {
        if (foo?.length != null) {
            foo.capitalize()  // this doesn't work because apparently foo might be null. Why?
        }
    }