logoalt Hacker News

ZenDroidyesterday at 9:55 PM1 replyview on HN

`lateinit var` was not added to Kotlin to handle nullability, but to address specific Android design where system components like Activity cannot realisticly initialize fields in their constructors. Outside of Android it shouldn't be too commonly used.


Replies

mike_hearnyesterday at 9:59 PM

"lateinit var" predates Android's adoption of Kotlin by years and was added because fields initialized after construction by frameworks are common in many contexts, but having nullability in the language makes that annoying.