Logo

Programming-Idioms

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

Idiom #140 Delete map entry

Delete from map m the entry having key k.

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

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

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