Having some issues creating a slice of interfaces and initiating it to its concrete type, any help would be greatly appretiated
Interface
type MatrixElement interface {
GetValue() Element
GetCoordinate() Coordinate
}
Concrete Implementation
type LocatableElement struct {
value datastructures.Element
coordinate datastructures.Coordinate
}
func (ele LocatableElement)GetValue() datastructures.Element {
return ele.value
}
func (ele LocatableElement)GetCoordinate() datastructures.Coordinate {
return ele.coordinate
}
func CreateLocatableElement(value datastructures.Element, coordinate datastructures.Coordinate) LocatableElement {
return LocatableElement{
value: value,
coordinate: coordinate,
}
}
Defining the Type as a slice
type HorizontalMatrix [][]datastructures.MatrixElement
Creating an instance of the new HorizonatlMatrix
func CreateHorizontalMatrix(rows int, columns int) HorizontalMatrix {
horzMatrix := make([][]matrix.LocatableElement, rows)
for i := 0; i < rows; i++ {
horzMatrix[i] = make([]matrix.LocatableElement, columns)
}
return horzMatrix;
}
cannot use horzMatrix (type [][]matrix.LocatableElement) as type HorizontalMatrix in return argument