Is it possible to access `isInitialized` on a loca...
# announcements
s
Is it possible to access
isInitialized
on a local variable (ie. not property)
lateinit var
? If so what is the syntax
p
Why do you need that? Why don’t you make it nullable and just check for null?
s
Because it is captured by a lambda and so autocasting stop working
As a workaround I assign it to a
val
and use that for autocasting
👍 1
j
if (::yourVar.isInitialized) {//your stuff)
s
Gives me a
Error:(46, 11) Kotlin: Unsupported [References to variables aren't supported yet]
Assuming you mean:
Copy code
fun foo(){
    lateinit var bar: String
    if (::bar.isInitialized){

    }
}
j
i guess it is only valid for properties then… sorry