Kotlin Tutorial #15: Delegation — by lazy, Delegates, and Custom Delegation

In the previous tutorial, you learned about error handling. Now let’s learn about delegation. Delegation is a design pattern where an object hands off work to another object. Kotlin has built-in support for delegation using the by keyword. In this tutorial, you will learn: by lazy — lazy initialization Delegates.observable — react to changes Delegates.vetoable — reject invalid changes Map delegation — properties from a map Custom delegates — build your own Class delegation — delegate interface implementation by lazy by lazy creates a property that is computed only once, the first time you access it. After that, the cached value is returned. This is useful for expensive initialization. ...

March 22, 2026 · 8 min