I want to use this feature
the simplest thing like in the example does not work for me:
lateinit val foo = 1
val bar = foo::lateinitVar.isInitialized()
But I am getting
unresolved reference lateinitVar
I am using Kotlin 1.2.10 via gradle in Android-Studio (also the Kotlin 1.2.10 plugin installed there)
There’s no variable with name
lateinitVarin your code, thus the error. Look at the example again:There’s a variable
lateinitVardefined inthis, which the function is called on. The code snippet in the example can be expanded (little plus sign at the beginning of the listing) and looks as follows:This might make it more clear.
Also, be aware that
lateinitcan’t be applied tovalbut onlyvar.