Android ● ● ○ Kotlin 2.0

Kodebits Day 74: Lateinit Property

Aug 12 2026
Practice lateinit with a short kotlin challenge.

What is the output?

class Service {
  lateinit var db: String
  fun check() =
    ::db.isInitialized
}
fun main() {
  val s = Service()
  println(s.check())
  s.db = "prod"
  println(s.check())
}


Try it in the online Kotlin Playground →

[spoiler title="Solution"]

Answer:

false
true

Explanation:

lateinit properties can be checked with ::property.isInitialized before use.

[/spoiler]


Further Reading