mirror of
https://github.com/adambard/learnxinyminutes-docs.git
synced 2024-12-23 09:41:36 +00:00
correct minor grammar and formatting to improve readability
This commit is contained in:
parent
e9fbf8f24a
commit
4de15e41b3
@ -108,12 +108,13 @@ can include line breaks.` // Same string type.
|
|||||||
bs := []byte("a slice") // Type conversion syntax.
|
bs := []byte("a slice") // Type conversion syntax.
|
||||||
|
|
||||||
// Because they are dynamic, slices can be appended to on-demand.
|
// Because they are dynamic, slices can be appended to on-demand.
|
||||||
// To append elements to a slice, built-in append() function is used.
|
// To append elements to a slice, the built-in append() function is used.
|
||||||
// First argument is a slice to which we are appending. Commonly,
|
// First argument is a slice to which we are appending. Commonly,
|
||||||
// the array variable is updated in place, as in example below.
|
// the array variable is updated in place, as in example below.
|
||||||
s := []int{1, 2, 3} // Result is a slice of length 3.
|
s := []int{1, 2, 3} // Result is a slice of length 3.
|
||||||
s = append(s, 4, 5, 6) // Added 3 elements. Slice now has length of 6.
|
s = append(s, 4, 5, 6) // Added 3 elements. Slice now has length of 6.
|
||||||
fmt.Println(s) // Updated slice is now [1 2 3 4 5 6]
|
fmt.Println(s) // Updated slice is now [1 2 3 4 5 6]
|
||||||
|
|
||||||
// To append another slice, instead of list of atomic elements we can
|
// To append another slice, instead of list of atomic elements we can
|
||||||
// pass a reference to a slice or a slice literal like this, with a
|
// pass a reference to a slice or a slice literal like this, with a
|
||||||
// trailing ellipsis, meaning take a slice and unpack its elements,
|
// trailing ellipsis, meaning take a slice and unpack its elements,
|
||||||
|
Loading…
Reference in New Issue
Block a user