a value of a mutable variable can change.
but the type can’t change.
It’s fixed on the type of a default value.
I think it’s safe in terms of type then.
Why can’t we use a smart cast with a mutable variable?
a value of a mutable variable can change.
but the type can’t change.
It’s fixed on the type of a default value.
I think it’s safe in terms of type then.
Why can’t we use a smart cast with a mutable variable?
Why do you think the type can’t change? We have a variable of type Animal
, we checked it is holding a Dog
currently, but then we can set it to a Cat
- we changed its runtime type.
I was an idiot… Thanks for helping me!