August 2019
Beginner to intermediate
798 pages
17h 2m
English
Arrays can have more than one dimension. However, using more than three dimensions without a serious reason can make your program difficult to read and might create bugs.
The following Go code shows how you can create an array with two dimensions (twoD) and another one with three dimensions (threeD):
twoD := [4][4]int{{1, 2, 3, 4}, {5, 6, 7, 8}, {9, 10, 11, 12}, {13, 14, 15, 16}}
threeD := [2][2][2]int{{{1, 0}, {-2, 4}}, {{5, -1}, {7, 0}}}
Accessing, assigning, or printing a single element from one of the previous two arrays can be done easily. As an example, the first element of the twoD ...
Read now
Unlock full access