# Multidimensional array

suggest change

Multidimensional arrays have other arrays as elements.

For example, `[2][3]int` represents an a 2 item array where each item is an array of 3 elements.

There are no limits for the number of dimensions, so you can have e.g. `[3][4][8][2]string` array.

Some examples:

``````// Defining a 2d Array to represent a matrix like
// 1 2 3     So with 2 lines and 3 columns;
// 4 5 6
multiDimArray := [2][3]int{[3]int{1, 2, 3}, [3]int{4, 5, 6}}

// That can be simplified like this:
var simplified = [2][3]int{{1, 2, 3}, {4, 5, 6}}

fmt.Println(multiDimArray)

fmt.Println(multiDimArray[0])

fmt.Println(multiDimArray[0][1])``````
``````[[1 2 3] [4 5 6]]
[1 2 3]
2
``````
``````// We can also define array with as much dimensions as we need
// here, initialized with all zeros
var multiDimArray = [2][4][3][2]string{}
fmt.Printf("%#v\n", multiDimArray)``````
``````[2][4][3][2]string{[4][3][2]string{[3][2]string{[2]string{"", ""}, [2]string{"", ""}, [2]string{"", ""}}, [3][2]string{[2]string{"", ""}, [2]string{"", ""}, [2]string{"", ""}}, [3][2]string{[2]string{"", ""}, [2]string{"", ""}, [2]string{"", ""}}, [3][2]string{[2]string{"", ""}, [2]string{"", ""}, [2]string{"", ""}}}, [4][3][2]string{[3][2]string{[2]string{"", ""}, [2]string{"", ""}, [2]string{"", ""}}, [3][2]string{[2]string{"", ""}, [2]string{"", ""}, [2]string{"", ""}}, [3][2]string{[2]string{"", ""}, [2]string{"", ""}, [2]string{"", ""}}, [3][2]string{[2]string{"", ""}, [2]string{"", ""}, [2]string{"", ""}}}}
``````
``````var multiDimArray = [2][4][3][2]string{}

// setting values at various locations:
multiDimArray[0][0][0][0] = "All zero indexes"
multiDimArray[1][3][2][1] = "All indexes to max"
fmt.Printf("%#v\n", multiDimArray)``````
``````[2][4][3][2]string{[4][3][2]string{[3][2]string{[2]string{"All zero indexes", ""}, [2]string{"", ""}, [2]string{"", ""}}, [3][2]string{[2]string{"", ""}, [2]string{"", ""}, [2]string{"", ""}}, [3][2]string{[2]string{"", ""}, [2]string{"", ""}, [2]string{"", ""}}, [3][2]string{[2]string{"", ""}, [2]string{"", ""}, [2]string{"", ""}}}, [4][3][2]string{[3][2]string{[2]string{"", ""}, [2]string{"", ""}, [2]string{"", ""}}, [3][2]string{[2]string{"", ""}, [2]string{"", ""}, [2]string{"", ""}}, [3][2]string{[2]string{"", ""}, [2]string{"", ""}, [2]string{"", ""}}, [3][2]string{[2]string{"", ""}, [2]string{"", ""}, [2]string{"", "All indexes to max"}}}}
``````