I think this has been asked before but I'm not sure why it isn't working
I have a couple of interfaces
interface SBoard {
val size: Int
}
interface GBoard<T> : SquareBoard {
}
with classes
open class SBoardImpl (override val size: Int) : SBoard {
lateinit var allCells: Array<Array<CellImpl>>
init {
println ("Parent Generator: " + this.size.toString())
}
...
}
class GBoardImpl<T> (override val size: Int): SBoardImpl (size), GBoard<T>{
lateinit var cellValues: Array<Array<Any?>>
init {
println ("Child Initialisation:" + super.size.toString())
}
...
}
when I create GBoardImpl like this
GameBoardImpl<T>(2)
e.g.
val g = createGBoard<Char>(2)
The size doesn't get passed to the super (SBoard) ? I get output of
Parent Generator: 0
I've ripped quite a bit out so I hope it still makes sense but essentially the SBoard init does get called (i.e. the parent) and the value of size is 0 instead of 2 (in this example). All the examples I've seen (or at least the way I've read them) show that the inclusion of the parameter in the method signature should pass it up
i.e.
class GBoardImpl<T> (override val size: Int): SBoardImpl (size)...
means that size gets passed to the SBoardImpl/Parent initialiser. Is that a misunderstanding or can anyone tell me what I've done wrong ?