View Problem

Check if a key exists in a map

Given a map pets {joe:cat,mary:turtle,bill:canary} print "ok" if an pet exists for "mary"
ExpandDiskEdit
ruby
puts "ok" if map.has_key?('mary')
ExpandDiskEdit
ruby
puts "ok" if map['mary'] # Only works if map entry can't be nil or false
DiskEdit
clojure
(if (contains? '{joe cat mary turtle bill canary} 'mary)
(println "ok"))

Submit a new solution for ruby or clojure
There are 25 other solutions in additional languages (cpp, erlang, fantom, fsharp ...)