A past puzzle — fully playable. 4 attempts, hints on wrong guesses.
stdle-124.go
1packagemain
2
3import"fmt"
4
5funcmain(){
6s:=[]int{1,2,3}
7t:=s[1:1]
8fmt.Println(len(t),cap(t))
9}
Slices
Answer & explanation
Console output
0 2
Why
s[1:1] has len high-low=0, so it is empty, but cap is cap(s)-low=3-1=2 because capacity is measured from the start offset to the array end. An empty slice can still have spare capacity, ready to append into the trailing elements of the backing array.