A past puzzle — fully playable. 4 attempts, hints on wrong guesses.
stdle-19.go
1packagemain
2
3import"fmt"
4
5funcmain(){
6s:=[]int{5,6,7}
7dst:=make([]int,2)
8n:=copy(dst,s)
9fmt.Println(n,dst)
10}
Slices
Answer & explanation
Console output
2 [5 6]
Why
copy(dst, src) copies min(len(dst), len(src)) elements and returns that count. dst has len 2, so only 5 and 6 are copied and the return value is 2. The third source element 7 is ignored because the destination has no room.