Need Assistance?

support@tutorialshub.in

Null Safety (Kotlin's Superpower)

Safe Cast (as?) & ?.let { }

ADVERTISEMENT
Kotlin Free Lesson
5 min read
ADVERTISEMENT

Combine ?.let { ... } to run a block of code only when a nullable variable is non-null, and use as? to cast safely (returns null instead of throwing ClassCastException).

ADVERTISEMENT
Hi, I'm Tuby! Here to help you