Logo

Programming-Idioms

This language bar is your friend. Select your favorite languages!
  • Go

Idiom #331 Clear map

Remove all entries from the map m.

Explain if other references to the same map now see an empty map as well.

clear(m)

Since Go 1.21

Maps are reference types, so the underlying map is cleared for all references.
m.Clear();

All references see it's empty.

New implementation...
< >
programming-idioms.org