View Problem

Remove an entry from a map

Given a map pets {joe:cat,mary:turtle,bill:canary} remove the mapping for "bill" and print "canary"
ExpandDiskEdit
cpp C++/CLI .NET 2.0
if (pets->ContainsKey("bill"))
{
String^ value = safe_cast<String^>(pets["bill"]); pets->Remove("bill");
Console::WriteLine("{0}", value);
}
ExpandDiskEdit
fantom
pet := map.remove("bill")
echo ("pet=$pet")
DiskEdit
clojure
; Maps are immutable
; The following expression will return a new map without the 'bill key
(let [pets '{joe cat mary turtle bill canary}]
(println (get pets 'bill))
(dissoc pets 'bill))

Submit a new solution for cpp, csharp, fantom, or clojure
There are 21 other solutions in additional languages (erlang, fsharp, go, groovy ...)