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

Ray Eldath

12/19/2019, 11:58 AM
hi everyone. I want to know why there isn't something like
lateinit val
which is immutable after the initialization...? in my practice actually my
lateinit
is always for this immutable occasion... A friend of mine said that in the early version of Kotlin there is something like that, but then it's withdrawn. BTW, in KotlinConf 2018 Closing Panel many a speaker regarded
lateinit
as their most annoying Kotlin feature, and seems lots of audience agreed the opinion. I am wondering if this is because of the problem mentioned above...
c

cymessmer

12/19/2019, 10:08 PM
I think what you are looking for it
Copy code
// replace random logic with whatever makes sense for you
val x by lazy { Random(3).nextInt() }