Kotlin - Null Safety
Why is the safe cast operator as? preferred over the unsafe cast as in Kotlin when dealing with uncertain types?
Why is the safe cast operator as? preferred over the unsafe cast as in Kotlin when dealing with uncertain types?
as throws a ClassCastException if the cast fails.as? returns null instead of throwing, preventing runtime crashes.15+ quiz questions · All difficulty levels · Free
Free Signup - Practice All Questions