Create and Print Multi Dimensional Slice in Golang
This is a multidimensional in slice that stores inner in slices. So each element of the slice is another in slice. This is a short declaration of a multidimensional slice.
Example
package main
import "fmt"
func main() {
sales := [][]int{
{100, 200},
{300},
{400, 500},
}
for _, x := range sales {
for _, y := range x {
fmt.Println(y)
}
}
}
Output
100
200
300
400
500
Most Helpful This Week
Expected <type>, but got <type> error in Golang
How to add items to Slice using append function in Golang?
GO Program to Find the Largest Number Among Three Numbers
How to Improve the Performance of Your Golang Application?
How to initialize the slice with values using a slice literal?
Golang program for implementation of Radix Sort