internal class FractalNavStateImpl : FractalParent {
// ...
override lateinit var zoomAnimationSpecFactory: () -> AnimationSpec<Float>
my question is how he was able to override
zoomAnimationSpecFactory
and change its modifier from
val
to
lateinit var
without getting a compilation error?
😯 1
c
Casey Brooks
04/22/2022, 3:45 PM
Think of it in terms of what a property in an interface actually means. Interfaces cannot actually have backing fields which hold data, so all the compiler knows is that
val zoomAnimationSpecFactory
is effectively no different from
fun getZoomAnimationSpecFactory()
.
So when
FractalNavStateImpl
implements the interface,
override lateinit var
does still include that “get function” from the property, which means it is implementing everything required from the interface. It just also adds