```class Foo { var x: Int? = null } fun fn(foo...
# random
r
Copy code
class Foo {
   var x: Int? = null
}

fun fn(foo: Foo) {
   if (foo.x == null)
     return
   foo.x += 5
// Smart cast to 'Int' is impossible, because 'foo.x' is a mutable property that could have been changed by this timekotlin(SMARTCAST_IMPOSSIBLE)
}
???
a
Correct. It’s a mutable property. += assumes the foo is non null
r
so how do I do this the kotlin way?
y
foo.x?.let { foo.x += it }
j
Copy code
fun fn(foo: Foo) {
 foo.x = foo.x?.plus(5)
}