Why is it not possible to use lateinit with Boolean in Kotlin? I tried it with the other primitive data types and it works fine!
Here is the code that I want to use:
object BankAccount {
lateinit var accountName: String
lateinit var accountNumber: String
lateinit var accountStatus : Boolean
}
This is what the error says:
'lateinit' modifier is not allowed on properties of primitive types
lateinitdoesn't work with primitive or nullable types, because internally it usesnullas "uninitialized" value. Since fields of primitive types can't benull, the internallateinitmechanism can't work.You probably misread something.
lateinitdoesn't work with any primitive types.