David Kubecka
04/21/2023, 2:26 PMclass Delegate(val x: Int)
class A {
val delegate: Delegate
val x by this::delegate.x // how to do this?
}Adam S
04/21/2023, 2:28 PMclass Delegate(val x: Int)
class A(
val delegate: Delegate
) {
val x by this.delegate::x
}Joffrey
04/21/2023, 2:37 PMclass Delegate(val x: Int)
class A {
val delegate: Delegate
val x: Int get() = delegate.x
}
I find this clearer to read (but that's personal)David Kubecka
04/21/2023, 2:39 PMval s I would prefer that as well probablyJoffrey
04/21/2023, 2:41 PMx to be considered the same way in Delegate and in A you might want to define an interface for it (especially if you have more than one property). And then you can automatically delegate via interface delegationDavid Kubecka
04/21/2023, 2:47 PM