Go code
names := []string{"Maya", "Noah"}
fmt.Println(names)Line-by-line explanation
- Empty square brackets mean slice rather than fixed array.
- String is the item type.
- The values initialize the slice.
Expected output
[Maya Noah]This is the expected result.
A slice stores a small description pointing to an underlying array. It has a length and a capacity. You usually work with slices in everyday Go.