We're sorry but this app doesn't work properly without JavaScript enabled. Please enable it to continue.

This lesson's interactive features are locked, please to keep using them

Mutations

Insert an Element

m[key] = elem

Get an Element

elem = m[key]

Delete an Element

delete(m, key)

Check If a Key Exists

elem, ok := m[key]
  • If key is in m, then ok is true and elem is the value as expected.
  • If key is not in the map, then ok is false and elem is the zero value for the map's element type.

Assignment

It's important to keep up with privacy regulations and to respect our user's data. We need a function that will delete user records.

Complete the deleteIfNecessary function. The user struct has a scheduledForDeletion field that determines if they are scheduled for deletion or not.

Like slices, maps are reference types. When a map is passed into a function, we can make changes to the original – we don't have a copy.