3 ms·
> How can we protect ourselves from something that is beyond the language and is not controlled by it? There’s no way to do it. There are plenty of ways to do
by hota_mazi 10y ago
> How can we protect ourselves from something that is beyond the language and is not controlled by it? There’s no way to do it.
There are plenty of ways to do it. The most popular is probably to capture the Java nullability at the border when Java values enter Kotlin code. From that point on, your code is null correct and will never give you an NPE.
> The Smart cast to ‘Int’ is impossible, because ‘value’ is a mutable property that could have been changed by this time error is driving me nuts. I want to kill someone or break something.
Yeah, lash at the compiler for pointing out your code is incorrect, right? Easy solution: use a `val` (which should be your default anyway). Another solution, although less easy: write better code.