How do i initialize a lateinit var in kotlin?

Example:

lateinit var name: String

fun init() {
    name = "John"
}
Solution:

lateinit var name: String

fun init() {
    name = "John"  // Correctly initializing the lateinit variable
}
The `lateinit` keyword in Kotlin allows you to declare a non-nullable variable without immediately initializing it. You can initialize it later in the code when you're sure it has a non-null value.

Beginner's Guide to Kotlin