Issue
In the Go Slices tutorial (https://www.learn-golang.org/en/Slices), there's a statement that is factually incorrect:
"You can skip the capacity and length and only give the type to get an empty slice"
Followed by:
exampleSlice = make([]int)
Problem
make([]int) without any length or capacity parameters is not valid Go syntax. This code will not compile.
Solution
The statement and example should be corrected. To create an empty slice, the correct approaches are:
- Using zero value (nil slice):
- Using make with length 0:
exampleSlice := make([]int, 0)
- Using composite literal:
The make() function requires at least the type and length parameters for slices.