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]