Declare a slice without specifying size:
var nums []int
Note: no number in the brackets. This is what distinguishes slices from arrays. This creates a nil slice with length and capacity . A nil slice is perfectly valid but empty.
##### ###### ##### ### # # ### # # ###### ## ## ## ## ## ## ## # # # # # ## ##### #### ##### # # # # # # # #### ## # ## ## ## ## # # # # # ## ## # ###### ## ### # ### # ######
##### ###### ##### ### # # ### # # ###### ## ## ## ## ## ## ## # # # # # ## ##### #### ##### # # # # # # # #### ## # ## ## ## ## # # # # # ## ## # ###### ## ### # ### # ######
Basic syntax
Declare a slice without specifying size:
var nums []int
Note: no number in the brackets. This is what distinguishes slices from arrays. This creates a nil slice with length and capacity . A nil slice is perfectly valid but empty.