Create D slices:
matrix := make([][]int, 3)
for i := range matrix {
matrix[i] = make([]int, 4)
}
Each row is a separate slice. Rows can have different lengths. This creates a x grid where all rows have the same length.
##### ###### ##### ### # # ### # # ###### ## ## ## ## ## ## ## # # # # # ## ##### #### ##### # # # # # # # #### ## # ## ## ## ## # # # # # ## ## # ###### ## ### # ### # ######
##### ###### ##### ### # # ### # # ###### ## ## ## ## ## ## ## # # # # # ## ##### #### ##### # # # # # # # #### ## # ## ## ## ## # # # # # ## ## # ###### ## ### # ### # ######
Slices of slices
Create D slices:
matrix := make([][]int, 3)
for i := range matrix {
matrix[i] = make([]int, 4)
}
Each row is a separate slice. Rows can have different lengths. This creates a x grid where all rows have the same length.