main.go 源码
阅读全文
go main
main.go 源码
阅读全文
go main
main.go 源码
阅读全文
go Appending Quiz
Appending Quiz How does the append function work? It appends new elements to the given slice on the fly and returns a new slice, normally, it doesn't change the given slice CORRECT It appends new elem
阅读全文
go Slice Header Quiz
Slice Header Quiz What is a slice header? The first element of a slice value The first element of the backing array A tiny data structure that describes all or some part of a backing array CORRECT A d
阅读全文
go Slicing Quiz
Slicing Quiz What does this code print? nums := []int{9, 7, 5} nums = append(nums, 2, 4, 6) fmt.Println(nums[2:4]) [9 7 5 2 4 6] [5 2] CORRECT [4 6] [7 2] [9 7] 2: nums is [9 7 5 2 4 6]. So, nums[2:4]
阅读全文
go Backing Array Quiz
Backing Array Quiz Where does a slice store its elements? In the slice value In a global backing array that is shared by all the slices In a backing array that is specific to a slice In a backing arra
阅读全文
go The Mechanics of Append Quiz
The Mechanics of Append Quiz Which append call below allocates a new backing array for the following slice? words := []string{"lucy", "in", "the", "sky", "with", "diamonds"} words = append(words[:3],
阅读全文
go Slices vs Arrays Quiz
Slices vs Arrays Quiz Why you want to use a slice instead of an array? I like arrays more I want to create a dynamic collection, so I need an array A slice's length is dynamic, so I can create dynamic
阅读全文
go Advanced Slice Operations Quiz
Advanced Slice Operations Quiz What are the length and capacity of the 'part' slice? lyric := []string{"show", "me", "my", "silver", "lining"} part := lyric[1:3:5] Length: 1 - Capacity: 5 Length: 1 -
阅读全文