Start learning free

LESSON 106 OF 671 · ARRAYS I

Updating slice elements in Go

Lesson

The entries of slices are mutable and can be changed freely, using indices and the bracket notation, just like we do with static arrays:

names := []string{"Andy", "Mary", "Cody"}

names[0] = "Mircea"
names[2] = "Mike"

// names is now {"Mircea", "Mary", "Mike"}

Assignment
Follow the Coding Tutorial and let's play with some arrays.


Hint
Look at the examples above if you get stuck.


STEP 1 OF 2
    Ctrl + Enter to check