Dictionary.ContainsKey()

ContainsKey(dictionary, key) => Returns true if the dictionary has the specified key
Name Type Description
dictionary Dictionary Dictionary to search
key * Key to search for in dictionary

The examples below use the following dictionary:

SampleDictionary()
{'item1', 'apple'},
{'item2', 'kiwi'},
{'item3', 6},
{'item4', Date('12/19/2019')},
{'item5', 'kiwi'}
ContainsKey(SampleDictionary, 'item1'); => true
ContainsKey(SampleDictionary, 'item6'); => false

Dictionary.ContainsValue()

ContainsValue(dictionary, value) => Returns true if the dictionary has the specified value
Name Type Description
dictionary Dictionary Dictionary to search
value * Value to search for in dictionary

The examples below use the following dictionary:

SampleDictionary()
{'item1', 'apple'},
{'item2', 'kiwi'},
{'item3', 6},
{'item4', Date('12/19/2019')},
{'item5', 'kiwi'}
ContainsValue(SampleDictionary, 'apple'); => true
ContainsValue(SampleDictionary, 'banana'); => false

Dictionary.SetValueForKey()

SetValueForKey(dictionary, key, value) => returns the dictionary with the value set for the specified key

Note: The dictionary is mutable and is altered in place. The function returns the dictionary as a convenience for things like reduce.

Note: This function is aliased as set as well:

Dictionary.set(dictionary, key, value);
Name Type Description
dictionary Dictionary Dictionary to change the value in
key string Key to set (can be new or existing)
value * The new value to be set in the dictionary

Dictionary.ValueForKey()

ValueForKey(dictionary, key, default?) => Returns the value for a given key. Returns null (or default) if key not in dictionary

Note: This function is aliased as get as well:

Dictionary.get(dictionary, key, default?)
Name Type Description
dictionary Dictionary Dictionary to search
key * Key to return value of
default * (optional) a default value to return instead of null if the key does not exit

The examples below use the following dictionary:

SampleDictionary()
{'item1', 'apple'},
{'item2', 'kiwi'},
{'item3', 6},
{'item4', Date('12/19/2019')},
{'item5', 'kiwi'}
ValueForKey(SampleDictionary, 'item3'); => 6
ValueForKey(SampleDictionary, 'item6'); => null
ValueForKey(SampleDictionary, 'item6', 100); => 100

Dictionary.KeyForValue()

KeyForValue(dictionary, value) => Returns a list of keys that contain a specified value. Returns null if value not in dictionary
Name Type Description
dictionary Dictionary Dictionary to search
value * Value to return keys for

The examples below use the following dictionary:

SampleDictionary()
{'item1', 'apple'},
{'item2', 'kiwi'},
{'item3', 6},
{'item4', Date('12/19/2019')},
{'item5', 'kiwi'}
KeyForValue(SampleDictionary, 'kiwi'); 

returns the list [item2, item5]

KeyForValue(SampleDictionary, 6); 

returns the list [item3]

KeyForValue(SampleDictionary, 'banana'); 

returns null

Dictionary.Keys()

Keys(dictionary) => Returns a list of all keys in the dictionary
Name Type Description
dictionary Dictionary Dictionary to return list of keys from

The examples below use the following dictionary:

SampleDictionary()
{'item1', 'apple'},
{'item2', 'kiwi'},
{'item3', 6},
{'item4', Date('12/19/2019')},
{'item5', 'kiwi'}
Keys(SampleDictionary);

returns the list [item1, item2, item3, item4, item5]

Dictionary.Values()

Values(dictionary) => Returns a list of all values in the dictionary
Name Type Description
dictionary Dictionary Dictionary to return list of values from

The examples below use the following dictionary:

SampleDictionary()
{'item1', 'apple'},
{'item2', 'kiwi'},
{'item3', 6}, 
{'item4', Date('12/19/2019')},
{'item5', 'kiwi'}
Values(SampleDictionary);

returns the list [apple, kiwi, 6, 12/19/2019, kiwi]