const and lateinit
const val is a compile time constant. lateinit var is set later and avoids nullable types.
Example
const val MAX = 10
class Service {
lateinit var name: String
fun init() { name = "api" }
}
val s = Service()
s.init()
println("$MAX ${s.name}")Exercise
Set later.
var name: StringQuiz Test
These free lessons are for learning. Join a full course for projects, mentor feedback and a verified certificate.