notexOPENOverview
Notex/Languages/Deleting from Maps
01.23LESSON 23 OF 33 · 1 MIN READ

Deleting from Maps

Always free to read

Key-value pairs are removed from a map via the built-in delete function:

m := map[string]int{
    "hello": 5,
    "world": 10,
}
delete(m, "hello")

The delete function takes a map and a key and then removes the key-value pair with the specified key. If the key isn’t present in the map or if the map is nil, nothing happens. The delete function doesn’t return a value.

Progress is saved on this device.
KEEP EXPLORING

One note leads to another.

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