I am trying to simplay make a 2D array as a field on an object. I want a function that creates the object and returns it. But when trying to create the 2d array it returns a single array.
type Struct struct {
X int
Y int
Grid [][]bool
}
func NewLifeSimulator(sizeX, sizeY int) *Struct{
s := &Struct{
X: sizeX,
Y: sizeY,
Grid: make([][]bool, sizeX,sizeY), //Creates a regular array instead of 2D
}
return s
}
What do I need to change so that my function initializes a 2D array?