Commit 72d95410 authored by Him188's avatar Him188

Create delegate test

parent 576ade8c
package test
import kotlin.reflect.KProperty
data class Info(
var value: Int
) {
operator fun getValue(c: C, property: KProperty<*>): Int {
return value
}
}
class C(var info: Info) {
val value by info
}
fun main() {
val info = Info(1)
val c = C(info)
println(c.value) //1
info.value = 2
println(c.value) //2
c.info = Info(3)
println(c.value) //2
}
\ No newline at end of file
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment