Compare commits
2 Commits
master
...
inancgumus
Author | SHA1 | Date | |
---|---|---|---|
|
0dd6d4202c | ||
|
58440ddcf9 |
@@ -49,17 +49,20 @@ func main() {
|
|||||||
|
|
||||||
// ########################################################
|
// ########################################################
|
||||||
//
|
//
|
||||||
// #3: The previous code appends at the end of the names
|
// #3: Overwrite the name slice by creating a new slice
|
||||||
// slice:
|
// using make().
|
||||||
//
|
//
|
||||||
// ["" "" "" "" "" "einstein", "tesla", "aristo"]
|
// Adjust the make() function so that it creates a
|
||||||
|
// slice with capacity of 5, and puts the slice pointer
|
||||||
|
// to the first index.
|
||||||
//
|
//
|
||||||
// Append the new elements to the beginning of the names
|
// Then append the following names to the slice:
|
||||||
// slice instead:
|
|
||||||
//
|
//
|
||||||
|
// "einstein", "tesla", "aristo"
|
||||||
|
//
|
||||||
|
// Expected output:
|
||||||
// ["einstein", "tesla", "aristo" "" ""]
|
// ["einstein", "tesla", "aristo" "" ""]
|
||||||
//
|
//
|
||||||
// So: Overwrite and print the names slice.
|
|
||||||
//
|
//
|
||||||
// ...
|
// ...
|
||||||
// s.Show("3rd step", names)
|
// s.Show("3rd step", names)
|
||||||
|
@@ -31,19 +31,26 @@ func main() {
|
|||||||
//
|
//
|
||||||
// Observe how the slice and its backing array change.
|
// Observe how the slice and its backing array change.
|
||||||
//
|
//
|
||||||
|
// Expected output:
|
||||||
|
// ["" "" "" "" "" "einstein", "tesla", "aristo"]
|
||||||
|
//
|
||||||
names = append(names, "einstein", "tesla", "aristo")
|
names = append(names, "einstein", "tesla", "aristo")
|
||||||
s.Show("2nd step", names)
|
s.Show("2nd step", names)
|
||||||
|
|
||||||
// ########################################################
|
// ########################################################
|
||||||
//
|
//
|
||||||
// #3: The previous code appends at the end of the names
|
// #3: Overwrite the name slice by creating a new slice
|
||||||
// slice:
|
// using make().
|
||||||
//
|
//
|
||||||
// ["" "" "" "" "" "einstein", "tesla", "aristo"]
|
// Adjust the make() function so that it creates a
|
||||||
|
// slice with capacity of 5, and puts the slice pointer
|
||||||
|
// to the first index.
|
||||||
//
|
//
|
||||||
// Append the new elements to the beginning of the names
|
// Then append the following names to the slice:
|
||||||
// slice instead:
|
|
||||||
//
|
//
|
||||||
|
// "einstein", "tesla", "aristo"
|
||||||
|
//
|
||||||
|
// Expected output:
|
||||||
// ["einstein", "tesla", "aristo" "" ""]
|
// ["einstein", "tesla", "aristo" "" ""]
|
||||||
//
|
//
|
||||||
// So: Overwrite and print the names slice.
|
// So: Overwrite and print the names slice.
|
||||||
|
Reference in New Issue
Block a user