Sobes.tech
Junior — Senior

How do the properties 'lateinit' and 'nullable' interact when calling their methods

livecode

Task condition

Describe how the code will work, in which properties with the lateinit modifier and nullable properties are used, when attempting to call methods on them. Indicate what will happen during runtime, what exceptions may be thrown, or which calls will be safe.

class A {
    lateinit var first: Model
    var second: Model? = null
}

fun main() {
    val a = A()
    a.first.get()
    a.second?.get()
}