What does this Go slice length print?
values := []int{1, 2}
values = append(values, 3)
fmt.Println(len(values))Answer & explanation
Answer: 3
append returns a slice containing the original elements and the appended element.
Practice slices & arrays with self-contained questions. Check your answer, then use the explanation to understand the reasoning.
values := []int{1, 2}
values = append(values, 3)
fmt.Println(len(values))Answer: 3
append returns a slice containing the original elements and the appended element.