Slices
Slices are flexible views of arrays. Use append, len, cap and slicing a[1:3].
Example
package main
import "fmt"
func main() {
s := []int{1, 2, 3}
s = append(s, 4, 5)
fmt.Println(s, len(s), s[1:3], s[:2])
}Result
[1 2 3 4 5] 5 [2 3] [1 2]
Exercise
Add items.
s = (s, 4)
Quiz Test
These free lessons are for learning. Join a full course for projects, mentor feedback and a verified certificate.