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
Simple example of Map initialization in Go
How to iterate over a Map using for loop in Go?
How to replace emoji characters in string using regex in Golang?
Regular expression to extract domain from URL
How to import structs from another package in Go?
Sierpinski Carpet in Go Programming Language
How to rotate an image?
How to handle HTTP Get response?
Example: How to use ReadAtLeast from IO Package in Golang?
Copy an array by value and reference into another array