Need Assistance?

support@tutorialshub.in

Null Safety (Kotlin's Superpower)

Avoiding !! & lateinit vs by lazy

ADVERTISEMENT
Kotlin Free Lesson
5 min read
ADVERTISEMENT

Avoid !! (double-bang)—it forces a crash if null. When a non-null property is initialized later (e.g., dependency injection), use lateinit var; for expensive read-only properties computed only on first access, use val db by lazy { ... }.

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