Quick actions

cmd+k|ctrl+k

Navigation

Languages

Arrays / Multidimensional array / Essential Go

Snippet info

Language

Go

Visibility

public

Author

kkowalczyk

Created

2019-03-26T10:13:08Z

Updated

2019-03-26T10:13:08Z

package main

import "fmt"

func main() {

	var multiDimArray = [2][4][3][2]string{}

	// We can set some values in the array's cells
	multiDimArray[0][0][0][0] = "All zero indexes"   // Setting the first value
	multiDimArray[1][3][2][1] = "All indexes to max" // Setting the value at extreme location

	// The data looks like:
	// > [[[["All zero indexes" ""] ["" ""]] [["" ""] ["" ""]] [["" ""] ["" ""]]]
	//    [[["" ""] ["" ""]] [["" ""] ["" ""]] [["" ""] ["" ""]]]
	//    [[["" ""] ["" ""]] [["" ""] ["" ""]] [["" ""] ["" ""]]]
	//    [[["" ""] ["" ""]] [["" ""] ["" ""]] [["" ""] ["" ""]]]]
	//   [[[["" ""] ["" ""]] [["" ""] ["" ""]] [["" ""] ["" ""]]]
	//    [[["" ""] ["" ""]] [["" ""] ["" ""]] [["" ""] ["" ""]]]
	//    [[["" ""] ["" ""]] [["" ""] ["" ""]] [["" ""] ["" ""]]]
	//    [[["" ""] ["" ""]] [["" ""] ["" ""]] [["" ""] ["" "All indexes to max"]]]]

	fmt.Printf("%#v\n", multiDimArray)
}
INFO