August 2017
Intermediate to advanced
440 pages
10h
English
All previous delegates came from the standard library, but we can easily implement our own property delegates. We've seen that in order to allow a class to be a delegate, we need to provide the getValue and setValue functions. They must have a concrete signature, but there is no need to extend a class or implement the interface. To use an object as a delegate, we don't even need to change its internal implementation, because we can define getValue and setValue as extension functions. However, when we are creating custom classes to be delegates, then an interface may be useful:
Read now
Unlock full access