Question - When to use the lateinit keyword in Kotlin?
Answer -
Normally, properties declared as having a non-null type must be initialized in the constructor. However, fairly often this is not convenient.
For example, properties can be initialized through dependency injection, or in the setup method of a unit test. In this case, you cannot supply a non-null initializer in the constructor, but you still want to avoid null checks when referencing the property inside the body of a class. To handle this case, you can mark the property with the lateinit modifier.