notexOPENOverview
Notex/Languages/Practice: Slices and Arrays
01.17LESSON 17 OF 33 · 1 MIN READ

Practice: Slices and Arrays

Always free to read

The following exercises will help solidify your knowledge of slices.

  1. Starting from a nil []int, append one value at a time, printing length and capacity after each call until capacity reaches 16. Predict the sequence before you run it.

  2. Create s:= []int{1, 2, 3, 4, 5}. Take a subslice of length 3 starting at index 1, using a three-part slice expression to set its capacity to 3. Append 100 to the subslice. Print both slices and explain why the parent is unchanged.

  3. Use slices.EqualFunc together with strings.EqualFold to compare two []string values for case-insensitive equality. Cover the cases of equal, unequal, and different lengths.

Progress is saved on this device.
KEEP EXPLORING

One note leads to another.

Back to the library →
⌕
Search across the entire library ⌘ K