MR3Y
04/22/2022, 3:42 PMFractalParent that is declared as follows:
internal interface FractalParent : FractalNavScope {
// ...
val zoomAnimationSpecFactory: () -> AnimationSpec<Float>
// ...
}
and the class that implements the interface is:
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?Casey Brooks
04/22/2022, 3:45 PMval 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 fun setZoomAnimationSpecFactory(value), effectivelyephemient
04/22/2022, 3:53 PMephemient
04/22/2022, 3:54 PMinterface Base {
val foo
}
class Impl {
override var foo
private set
}
is a common pattern; this allows Impl and nothing else to update the valueMR3Y
04/22/2022, 4:19 PM