AI Features

Slice: Length and Capacity

Let’s learn about slice length and capacity.

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 a part of a slice or when we want to reference an ...