I get compiler errors about smartcasting mutable v...
# announcements
t
I get compiler errors about smartcasting mutable vars because it might have changed. Is there a way to disable that? It can't have changed because it's a single threaded app, and I checked for null in the previous statement, like
if( thing != null && thing.value > 10)
I can't use
thing?.value
because of a known bug in 1.5.20...
for those curious about the bug : https://youtrack.jetbrains.com/issue/KT-47717
d
You could grab a local reference:
Copy code
val myThing = thing
if (myThing != null && myThing.value > 10) foo()
t
ahh.. yeah.. good idea.
s
either the way Damien did it, or with
let
:
Copy code
thing?.let{ myThing->
  if(myThing>10) foo()
}
of course you don't have to name your local variable and use it as
it
.