-
Book Overview & Buying
-
Table Of Contents
Functional Kotlin
In the previous section, where we discussed delegation, we learned that delegation is a technique of method passing/forwarding.
For property delegates, it almost does the same. A property can pass its getter and setter calls to the delegate and the delegate can handle those calls on behalf of the property itself.
You're probably thinking, what is the benefit of passing getter and setter calls to the delegate? Only the delegate you're using can answer this question. Kotlin has multiple predefined standard delegations for most common use cases. Let's have a look at the following list, containing available standard delegates:
Delegates.notNull function and lateinitlazy functionDelegates.Observable functionDelegates.vetoble functionThink of a situation where you need to declare a property at the class level, but you don't have the initial value for the variable there. You'll get the value at some...