I'd like to create a custom Array in Kotlin.
class Node(val point: Point) {
var neighbour : Array<Node?> = Array(4, {_ -> null})
var prev : Byte = -1
}
Now, in another class, I tried to create an object like:
class OtherClass{
var field: Array<Array<Node?>> = Array(size.x, {_ -> Array(size.y, {_ -> null})})
}
So basically, I need a Grid of Nodes, all initialized with null. The provided sizes are of type Integer.
I get the following error:
Type inference failed. Expected type mismatch:
required: Array< Array< Node?>>
found: Array< Array< Nothing?>