Michael Friend
01/22/2020, 10:20 PMval casted = nullable as? String
and
val casted = nullable as String?
?
They both smart cast to String?
but do they both give null if nullable
is null and nullable
casted to a string (assuming the cast is possible)?
I know using as?
returns null if the cast fails and i assume option 2 would throw an exception, is that the only difference?Ruckus
01/22/2020, 11:02 PMRuckus
01/22/2020, 11:06 PM5 as String? // error
5 as? String // null
null as String? // null
null as? String // null
null as String // error