Hello, I have a lateinit variable that is initiali...
# getting-started
r
Hello, I have a lateinit variable that is initialized in
init()
but when I call the function
doSomething()
I have the exception "lateinit property c has not been initialized". I don't really get why as it has been initialized before. This is on Android. Thank you
t
Nothing guarantees that the init function is called before doSomething
Maybe you wanted to use the init {} block instead?
👍 3
r
Indeed when I use the init block and pass the context to the constructor it's working. Thanks !
k
But then you don't need a
lateinit
any more.
🙂 1