Grokking Go
0% completed
Appending Element And to the Another Slice
In Go, slices are dynamic, meaning we can add new elements or combine two slices using the built-in append() function. Since slices share memory with an underlying array, adding elements beyond capacity creates a new array automatically.
Appending Elements to a Slice
The append() function adds one or more elements to a slice and returns a new slice with the updated data. If the slice reaches its capacity, Go creates a new underlying array with increased size.
Syntax for Appending Elements to a Slice
.....
.....
.....
Like the course? Get enrolled and start learning!
Reading Progress
0%