Go code
names := []string{"Maya"}
names = append(names, "Noah")
fmt.Println(names)Line-by-line explanation
- A one-item slice is created.
- Append receives the slice and new value.
- The returned slice is assigned back to names.
- Both names are displayed.
Expected output
[Maya Noah]This is the expected result.