June 2018
Intermediate to advanced
316 pages
6h 34m
English
Implicit delegation is a language-level feature. With implicit delegation, we use a special language construction or keyword to implement delegation instead of overriding methods explicitly. There are two types of implicit delegation:
For unanticipated delegation, a delegate object can be replaced by another dynamically, whereas anticipated delegation doesn't let us change a delegate object during the delegating object's life cycle.
Kotlin supports only anticipated delegation as a language-level feature, but if Kotlin-supported unanticipated delegation, it could look as follows:
class CalculatorMachine(var delegate: Calculator): Calculator by delegateval calculator = CalculatorMachine(simpleCalculator) ...
Read now
Unlock full access