Introduce propertyDelegated method in delegates
This commit is contained in:
+17
@@ -0,0 +1,17 @@
|
||||
class Delegate {
|
||||
var name = ""
|
||||
fun get(t: Any?, p: PropertyMetadata): String = name
|
||||
fun propertyDelegated(p: PropertyMetadata) { name = p.name }
|
||||
}
|
||||
|
||||
class A {
|
||||
private val prop by Delegate()
|
||||
|
||||
fun test(): String {
|
||||
return if (prop == "prop") "OK" else "fail"
|
||||
}
|
||||
}
|
||||
|
||||
fun box(): String {
|
||||
return A().test()
|
||||
}
|
||||
Reference in New Issue
Block a user