Delegates in Kotlin
Kotlin has out-of-the-box support for delegation. Kotlin provides you with some standard delegates for properties for most common programming needs. Most of the time, you'll find yourself using those standard delegates, instead of creating your own one; however, Kotlin also allows you to create your own delegate, as per your requirements.
Not only delegation for properties, Kotlin also allows you to have delegated classes.
So basically, there are two types of delegation in Kotlin, which are as follows:
- Property delegation
- Class delegation
So, let's have a look at the property delegation first, and then we will move ahead with class delegation.