Vladyslav Sitalo
10/18/2018, 9:08 AMlateinit does not work with the basic types (e.g. `Int`/`Long`/etc)? Googling tells me that it’s because of the way kotlin represents those types, but It’s still fuzzy for me. So I’d appreciate a link or an explanation 🙂Egor Trutenko
10/18/2018, 9:11 AMlateinit properties with @NonNull and on access checks whether they are null or not. If they are, it throws PropertyUninitializedException. As you may understand already, primitive types can't be null, because they are not reference types, thus the restriction.Vladyslav Sitalo
10/18/2018, 9:13 AMInt?), and I presume they represented via Integer instead of int why can’t it be the same for lateinit?Egor Trutenko
10/18/2018, 9:17 AMlateinit behavior, or handling light primitive values on your own?Vladyslav Sitalo
10/18/2018, 9:23 AMlateinit marked variable be another special case?karelpeeters
10/18/2018, 9:24 AMEgor Trutenko
10/18/2018, 9:34 AMlateinit is to postpone property initialization, because naturally all properties in Kotlin must be initialized on definition or on class construction, so it basically has nothing to do with nullability. Nullability is just how it's internally implemented and why it's confined in applicable types. And yes, it's a terribly looking hack, but, for example, Android couldn't live without it.karelpeeters
10/18/2018, 9:41 AMEgor Trutenko
10/18/2018, 9:48 AMonCreate(), that's why they need lateinit property. But then, why would you need lateinit primitives at all? That's just ideologically incorrect.