https://kotlinlang.org logo
#android
Title
# android
a

Alf_

04/15/2019, 9:56 AM
i.e.: Activity have an TextView that must be updated since Fragment but this TextView is a lateinit var that might not have been initialized when thisFragment updates its value. I am trying to check if it's null with ? operator but this always give me that variable cannot be null.
g

gildor

04/15/2019, 9:58 AM
If you need to check lateinit property, usually it sign that you just need nullable property instead
👍 1
✔️ 1
a

Alf_

04/15/2019, 9:59 AM
Okey I am going to update that textview to nullable property
g

gildor

04/15/2019, 9:59 AM
There is special
::property.isInitialized
intrinsic, but I wouldn’t recommend to use it, just make property nullable
a

Alf_

04/15/2019, 10:00 AM
Yup I know about that but it's only working in the class that contains the lateinit property if I call that outside the Activity class that contains the property it does not work
😞
Nullable property lets go -!!
Thanks!
g

gildor

04/15/2019, 10:01 AM
Again, if you have case when property have to be checked just use nullable, this is exactly why nullable exist
a

Alf_

04/15/2019, 10:09 AM
Okey @gildor thank you dude!
👍 1