has
check if a dict has a given key, or a list has a given index
(any xs, any key) -> boolean
If xs
is a dict, casts key
to string and returns whether key
is a key in xs
.
If xs
is a list, casts key
to long and returns whether key
is an existing index in xs
.
Returns nil
if xs
is nil
.
Throws an error if xs
is not a list or dict.
Parameters
Name | Type | Description |
---|---|---|
xs |
dict or list | The dict or list to check |
key |
string or long | The key or index to access |