https://kotlinlang.org logo
#announcements
Title
# announcements
m

maciekjanusz

05/19/2017, 10:15 AM
lateinit var a: String
makes it possible to have non-nullable type and yet allow for this edge case of it being null until properly assigned value AFTER construction
l

louiscad

05/19/2017, 11:58 AM
maciekjanusz: But using
var a = 0
can work too, avoiding autoboxing
m

maciekjanusz

05/19/2017, 12:04 PM
that's beside the point of
lateinit
, you cannot use
lateinit
on properties with initializer
also, I have to correct my example, one cannot use
lateinit
with primitives also
l

louiscad

05/19/2017, 12:13 PM
More accurately
lateinit
would be pointless if first init is not late, but in the initializer instead 😉
2 Views