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

alex.tavella

11/26/2017, 11:09 PM
The problem I see with lateinit is that your property is not immutable, I still prefer to use lazy delegate with no thread safety argument
r

rkeazor

11/27/2017, 11:12 AM
@alex.tavella Making something immutable isnt the usecase for lateinit . But when it comes to instaniating views why would you want it to be immutable knowing how android's lifecycle works... i think the best solution is to use what has less overhead. Lateinit should always be choosen over delegate lazy when it comes to view variables.
a

alex.tavella

11/27/2017, 11:26 AM
Does the view references really leak if you use lazy delegate? Regarding to lazy delegate overhead, it is only on first call right? It should be better than call findViewById everytime (which I suppose is what android extensions does behind the scenes)
a

akshaychordiya

11/27/2017, 11:31 AM
`Kotlin Android Extension`calls
findViewById
only once and for further calls it gets the view from cache
👍 1
3 Views