Slice: Length and Capacity
Explore how to determine and manage the length and capacity of slices in Go, including creation with the make() function and efficient appending using the ... operator. Develop a clear understanding of slice properties to write better performing Go code.
We'll cover the following...
We'll cover the following...
About slice length and capacity
Both arrays and slices support the len() function for finding out their length. However, slices also have an additional property called capacity that can be found using the cap() function.
Note: The capacity of a slice is really important when we want to select ...