Member-only story
Kotlin Cheat Sheet for Android Developers 🚀
8 min readSep 27, 2024
Developers Assemble! đź—ż
Hello you genius developers, welcome to yet another part of our ongoing Kotlin series where we’ll be covering the essentials you’ll use daily to create fantastic apps 🤗
Let’s explore the cheat sheet, then!
🌟Members can scroll down to enjoy! Non-members, click here for full access.🌟
1. val
vs var 🤧
val
: Immutable reference (likefinal
in Java). You cannot reassign a value once assigned.var
: Mutable reference. The value can change during runtime.
2. lateinit ⏰
- What: Allows initializing a non-null variable later, typically for dependency injection or unit testing.
- Why: Used when you cannot initialize a variable at the time of declaration, often for classes or Android views.
- Use case: Fragment fields injected by frameworks.