Kotlin – How to decide between “lateinit” and “nullable variable”?

A type that is nullable is just that, a thing that has a valid state that is null.

A non-nullable late init var represents something where null is an invalid state, but for some reason you can’t populate it in the constructor.

Android Activities are a good example of a use of lateinit. Activities must have a no args constructor and their lifecycle only really starts with onCreate().

Leave a Comment

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)