Teknight
01/17/2019, 2:22 PMclass MyClass: IDelegate by MyDelegatedClass()
Can i access the MyClass instance from within MyDelegatedClass in any way?hudsonb
01/17/2019, 2:25 PMclass MyClass(val delegate: MyDelegatedClass = MyDelegatedClass()) : IDelegate by delegate
Then you can access it via delegate
if you'd likehudsonb
01/17/2019, 2:29 PMTeknight
01/17/2019, 2:29 PMAlowaniak
01/17/2019, 2:29 PMAlowaniak
01/17/2019, 2:30 PMclass MyClass: IDelegate by MyDelegatedClass(this)
right?hudsonb
01/17/2019, 2:30 PMMyDelegatedClass
has no no knowledge of MyClass
unless you provide it via something like class MyClass: IDelegate by MyDelegatedClass(this)
Alowaniak
01/17/2019, 2:30 PMthis
is valid there yetTeknight
01/17/2019, 2:30 PMAlowaniak
01/17/2019, 2:31 PMhudsonb
01/17/2019, 2:31 PMTeknight
01/17/2019, 2:31 PMTeknight
01/17/2019, 2:32 PMTeknight
01/17/2019, 2:34 PMTeknight
01/17/2019, 2:34 PMAlowaniak
01/17/2019, 3:12 PMthis
but only a part of it and you can extract that so you get interface A
class MyA(private val b: PartialB) : A
class FullB(private val partialB: PartialB = PartialB()) : A by MyA(partialB)
class PartialB
And quite possibly maybe there are even better solutionsDico
01/18/2019, 1:34 AM