From ca6cb1b19667c35d8126d0e5070adfef067adee3 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=C4=B0nan=C3=A7=20G=C3=BCm=C3=BC=C5=9F?= Date: Wed, 31 Mar 2021 13:33:14 +0300 Subject: [PATCH] update: adv ops exercise #1 --- .../22-adv-ops-practice/solution/main.go | 17 ++++++++++++----- 1 file changed, 12 insertions(+), 5 deletions(-) diff --git a/16-slices/exercises/22-adv-ops-practice/solution/main.go b/16-slices/exercises/22-adv-ops-practice/solution/main.go index 2664ee4..abe550c 100644 --- a/16-slices/exercises/22-adv-ops-practice/solution/main.go +++ b/16-slices/exercises/22-adv-ops-practice/solution/main.go @@ -31,19 +31,26 @@ func main() { // // Observe how the slice and its backing array change. // + // Expected output: + // ["" "" "" "" "" "einstein", "tesla", "aristo"] + // names = append(names, "einstein", "tesla", "aristo") s.Show("2nd step", names) // ######################################################## // - // #3: The previous code appends at the end of the names - // slice: + // #3: Overwrite the name slice by creating a new 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 - // slice instead: + // Then append the following names to the slice: // + // "einstein", "tesla", "aristo" + // + // Expected output: // ["einstein", "tesla", "aristo" "" ""] // // So: Overwrite and print the names slice.