Logo

Programming-Idioms

Delete from map m the entry having key k.

Explain what happens if k is not an existing key in m.
Implementation
Go

Implementation edit is for fixing errors and enhancing with metadata. Please do not replace the code below with a different implementation.

Instead of changing the code of the snippet, consider creating another Go implementation.

Be concise.

Be useful.

All contributions dictatorially edited by webmasters to match personal tastes.

Please do not paste any copyright violating material.

Please try to avoid dependencies to third-party libraries and frameworks.

Other implementations
use std::collections::HashMap;
m.remove(&k);
m.remove(k);
m.delete(k)
m = Map.delete(m, k)
uses ghashmap;
m.delete(k);
import Data.Map.Strict
import Data.Map.Lazy
delete k m
m.pop(k, None)
m.erase(k);
unset($m[k]);
m.delete(k)
m - k
m -= k
Map myMap = {};
myMap.remove(key)
map.remove(k);
System.Collections.Generic
map.Remove(key);
delete $m{$k}; # also succeeds when $k does not exist in %m
(dissoc m k)
m[k]=nil