I have a class
data classOuter (
val str: String = "fOo"
...
val innerClassInstance: InnerClass= InnerClass(),
) {
...
inner class InnerClass {
fun foo () {
return str.toLowerCase()
}
}
}
But I get an error:
Constructor of inner class InnerClass can be called only with receiver of containing class
Is there way to avoid it ?
val innerClassInstance: InnerClass = InnerClass()to mean. As it is, that does not make sense. What instance ofOuterdo you want to create anInnerClassout of? And whatever your answer is, ask yourself where that instance ofOutercomes from.