Learn Data Structures and Algorithms with Golang
上QQ阅读APP看书,第一时间看更新

Slices

Go Slice is an abstraction over Go ArrayMultiple data elements of the same type are allowed by Go arrays. The definition of variables that can hold several data elements of the same type are allowed by Go Array, but it does not have any provision of inbuilt methods to increase its size in Go. This shortcoming is taken care of by Slices. A Go slice can be appended to elements after the capacity has reached its size. Slices are dynamic and can double the current capacity in order to add more elements.

Let's take a look at the len function in the next section.