any chance this is possible somehow? `class C: If...
# getting-started
m
any chance this is possible somehow?
class C: Iface by Delegate(this)
I understand C instance isn't fully constructed at this point and passing it's reference is risky but it would be useful
m
Why would you need that? If the
Delegate
would call anything on the
C
instance, it would cause an infinite loop, wouldn't it?
Lets say
C
has a method
f
. A call to
f
is delegated to
Delegate
, which, if it would call
f
on its instance, would be delegated to itself again.
m
C would extend some class like Activity and have methods other than those in
Iface
class C: Superclass(), Iface by Delegate(this as Superclass)
This would be composition where inheritance is usually used
r
How is delegating to yourself any different than just implementing the interface?
m
I'm trying to skip manual initialization step in this example here https://medium.com/@fardavide/composition-over-inheritance-on-activity-and-fragment-d484aa92e572
k
I agree this would be very useful, so far I've only been able to work around it because I also have property delegate providers and "steal" the
this
instance there.
d
And poke JB, it's been some time 😅