Lateinit is an important initialization property, because if you don't want to initialize your variable in constructor, lazy and lateinit can be employed to do so. In this recipe, we will see how to use the lateinit modifier and how it is different from the lazy modifier.
Using the lateinit modifier
Getting ready
I'll be using IntelliJ IDEA for the coding purpose; you can use any IDE that can execute Kotlin code.
How to do it…
Let's follow the given steps to understand how the lateinit modifier works:
- In Java, we could just declare a variable...