3 ms·
A lot of the language rules are required to make its approach to nullability work. Hence odd keywords like "lateinit var".
by mike_hearn 4mo ago
A lot of the language rules are required to make its approach to nullability work. Hence odd keywords like "lateinit var".
- ZenDroid 4mo ago`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.
- mike_hearn 4mo ago"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.