August 2019
Beginner to intermediate
798 pages
17h 2m
English
Arrays are one of the most popular data structures for two reasons. The first reason is that they are simple and easy to understand, while the second reason is that they are very versatile and can store many different kinds of data.
You can declare an array that stores four integers as follows:
anArray := [4]int{1, 2, 4, -4}
The size of the array is stated before its type, which is defined before its elements. You can find the length of an array with the help of the len() function: len(anArray).
The index of the first element of any dimension of an array is zero; the index of the second element of any array dimension is one and so on. This means that for an array with one dimension named a, the valid indexes are from 0 to len(a)-1 ...
Read now
Unlock full access