1 Add elements to slice, we use append to bring the function.
From the above steps we know s2=[5,6], continue to add data to slice more than the CAP, the system itself will open up a new underlying array for ease of use, but also remove the unused slice.
2 Examples:
Note that there is no null in the go language, he replaces the concept with nil , and that is, in the Go language, nil refers to 0, that is, its empty is 0, unless the condition is set, otherwise there is no way to execute the meaning oh.
For example, the first nil in this case
3 make (with function) usage: The makes function can display the contents of the array, the length (lens), and the Capacity (CAP).
The output of the S1,S2,S3 is:
4 Copy Slice
Copy (b), copy B to a as a template.
5 Delect Slice
Delete Intermediate data
Note Here s2[4:] ... In the "..." usage, when we want to take s2[4:] All the elements, need to add ... to fetch.
Remove the elements from the tail:
Note the use of the function Len when removing the trailing element.
The output is:
6 Operation of Map:
(1) Set the value:
Three ways of expression:
Note: Before a colon in map denotes key, the colon indicates value.
(2) Traverse map:
As before, we use range.
(3) Value:
The output is:
Make the following explanations:
The first OK we can take the value of this key called course is Golang;
So show as Ture
The second OK is assigned to couse at the time of assignment, and the key is not couse in our defined map, so this OK value is false.