16-slices/questions/6-capacity.md
2: The length is never greater than the capacity.
3: The length and capacity of a slice can be equal.
2: The capacity's type is int, it cannot be nil.
[]string{"I", "have", "a", "great", "capacity"}
1: That's right! A slice literal creates a new slice value with equal length and capacity.
words := []string{"lucy", "in", "the", "sky", "with", "diamonds"}
words = words[:0]
3: Right!
words[:0]slices for 0 elements, which in turn returns a slice with zero-length. Because thewordsslice points to the same backing array, its capacity is equal to 6.
words := []string{"lucy", "in", "the", "sky", "with", "diamonds"}
words = words[0:]
2: Right!
words[0:]slices for the rest of the elements, which in turn returns a slice with the same length as the original slice: 6. Beginning from the first array element, thewordsslice's backing array contains 6 elements; so its capacity is also 6.
words := []string{"lucy", "in", "the", "sky", "with", "diamonds"}
words = words[2:cap(words)-2]
4: Right!
words[2:cap(words)-2]is equal towords = words[2:4], so it returns:["the" "sky"]. So, its length is 2. But there are 4 more elements (["the" "sky" "with" "diamonds"]) in the backing array, so the capacity is 4.