Yevhenii Nadtochii
04/30/2020, 2:04 PMinterface Action
class Outer(doer: Doer = this.Doer()) : Action by doer { //'this' is not defined in this context
inner class Doer : Action
}
or
interface Action
class Outer : Action by Doer() { //Constructor of inner class Doer can be called only with receiver of containing class
inner class Doer : Action
}
thanksforallthefish
04/30/2020, 2:32 PMinner
? inner
classes requires an instance of the outer class to be instantiated. eg
val outer = Outer()
val inner = outer.Inner()
and ofc you don’t yet have an instance of the outer class when you are instatiating the outer class itselfinterface Action
class Outer(doer: Doer) : Action by doer {
inner class Doer : Action
}
is legal, the problem you are having is not delegating, but instantiatingYevhenii Nadtochii
04/30/2020, 2:38 PM