Slice
Slices use arrays as the underlying data type. The main advantage is that slices can be resized, unlike arrays. Think of slices as a viewing window in to an underlying array. The capacity refers to the size of the underlying array, and the maximum possible length of a slice. The length of a slice refers to its current length which can be resized.
Slices are created using the make() function. The make() function will create a slice of a certain type with a certain length and capacity. The make() function can be used two ways when creating a slice. With only two parameters, the length and capacity are the same. With three parameters, you can specify a maximum capacity larger than the length. Here are two of the make() function declarations: ...
Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Read now
Unlock full access