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
How to trim leading and trailing white spaces of a string in Golang?
Data encryption with AES-GCM
How can I convert a string variable into Boolean, Integer or Float type in Golang?
How to find the type of the variable by different ways in Golang?
How to check UPPERCASE characters in a string in Golang?
Copy an array by value and reference into another array
Example of Switch Case with Break in For Loop
How to fetch an Integer variable as String in Go?
Example of Pointers with Struct
How to check if a map contains a key in Go?