Skip to content

Instantly share code, notes, and snippets.

@rcoproc
Last active March 1, 2020 19:58
Show Gist options
  • Save rcoproc/cc11f38a28da59f77f0956bedda7d90b to your computer and use it in GitHub Desktop.
Save rcoproc/cc11f38a28da59f77f0956bedda7d90b to your computer and use it in GitHub Desktop.
Multi Dimensional array with for range navigation
package main
import "fmt"
func main() {
a := [...][2]int{{1, 2}, {3, 4}, {5, 6}}
fmt.Printf("Array is %v and type of array element is %T", a, a[0])
fmt.Println("")
for parent, child := range a {
for _, item := range child {
fmt.Printf("Item %d of Array %d\n", item, parent)
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment