Junior — Senior
Output investigation when working with append and shared slice capacities
livecode
Task condition
It is necessary to predict which values will be printed by the program that uses slices and the append function, as well as to provide an explanation of the obtained output, considering the shared capacity and the behavior of slices in Go.
package main
import (
"fmt"
)
func main() {
s1 := make([]int, 0, 10)
s1 = append(s1, []int{1, 2, 3, 4, 5}...)
s2 := append(s1, 6)
s3 := append(s1, 7)
fmt.Println(s1, s2, s3)
}