A delegated property keeps ordinary property syntax while moving storage or accessor behavior to a helper object. This removes repeated getter and setter logic when properties need lazy loading, validation, change notifications, or storage outside a backing field. section 9.5 section 9.5.4
var p: Type by Delegate()
The expression after `by` creates or supplies the delegate that handles property access. section 9.5.1
For `var p: Type by Delegate()`, Kotlin evaluates the delegate expression and stores the result in a hidden helper property. Reads call `getValue`; writes call `setValue`. A `val` needs only `getValue`. Delegate functions are marked `operator` and may be members or extensions; `provideDelegate` can validate or customize delegate creation. section 9.5.1 section 9.5.4
Lazy initialization without manual state
Use `val emails by lazy { loadEmails(this) }` instead of a nullable backing property plus a custom getter. The lambda initializes the value on first access. `lazy` is thread safe by default, with options for different locking behavior or no synchronization when multithreading is irrelevant. section 9.5.2
Observable mutable properties
A delegate can hold a value and notify observers whenever it changes. `var age by ObservableProperty(age, this)` and `var salary by ObservableProperty(salary, this)` replace duplicated setter code. `Delegates.observable` supplies a standard-library alternative that receives the property, old value, and new value. section 9.5.3 section 9.5.3
Delegates also support framework-level property behavior:
- A database column can act as a delegate: reading `user.age` retrieves an entity value, and writing it updates the mapped value and marks the entity dirty. section 9.5.6
- Any map can serve as a property delegate for objects with variable sets of attributes. section 9.6
Delegation changes implementation, not use: clients still read and assign properties normally. It centralizes logic for how values are stored, initialized, accessed, and modified while preserving concise Kotlin APIs. section 9.5.4 section 9.6
