Kotlin Delegated properties Custom delegation


Example

class MyDelegate {
    operator fun getValue(owner: Any?, property: KProperty<*>): String {
        return "Delegated value"
    }
}

val foo : String by MyDelegate()
println(foo)

The example prints Delegated value