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
Read and Write Fibonacci series to Channel in Golang
Empty Interface Type in Go Programming Language
Modernizing Legacy Applications: Critical Tips for Organizational Upgrades
How to concatenate two or more slices in Golang?
How to set timeout for http.Get() requests in Golang?
Example of Sscan vs Sscanf vs Sscanln from FMT Package
Golang Concurrency Best Practices
GO Program to Generate Fibonacci Sequence Up to a Certain Number
Top Programming Languages Behind Blockchain App Development
Golang panic recover example