https://kotlinlang.org logo
#compiler
Title
# compiler
s

Shreyas Patil

02/14/2022, 1:32 PM
I know the reason due to which I'm able to write this without any issues. But should I be able to do that with strict type checking?
e

ephemient

02/14/2022, 1:51 PM
null
inhabits all
T?
, and value is smart-cast to null. why shouldn't you be able to?
p

Paul Woitaschek

02/14/2022, 2:27 PM
Yep. In line 7 the compiler knows it's null. And setInt accepts nulls.
2 Views