contains(obj, key)
Return true
if the object obj
knows about an association for key
,
otherwise return false
.
Contains
is a generic method.
let t = #{'a:10, 'b:20}
contains(t, 'a)
// true
contains(t, 'c)
// false
// A custom type that can keep track of keys-value mappings:
function make_table(xys)
^(msg)
| 'contains -> ^(k) if (assoc(k, xys)) true else false
let t2 = make_table(['a:10, 'b:20, 'c:30])
contains(t2, 'c)
// true
contains(t2, 'a)
// true
contains(t2, 'z)
// false