We can add elements to the end of a slice using the built-in append() function.
append() takes the slice and one or more new values, and returns a new slice with those values added to the end:
arr1 := []int{1, 2, 3}
arr1 = append(arr1, 4)
// arr1 is now {1, 2, 3, 4}
Assignment
Follow the Coding Tutorial and let's play with some arrays.
Hint
Look at the examples above if you get stuck.
Free plan: 30 tutor messages. PRO is unlimited.
Saved
Ctrl + Enter to check
