Dictionary Functions

DictAdd(dict, key1, value1, …) : Dict?

Adds key-value pairs into a dictionary.
Updates source dict in place if possible, otherwise returns new dictionary.

DictAdd Parameters

dict : Dict?

key1 : ?

value1 : ?

? : ?

DictAdd Examples

var ok = { A=1 }.DictAdd('B', 2) == { A=1, B=2 };
var ok = { A=1 }.DictAdd('B', 2, 'A', 2) == { A=2, B=2 };

DictKeys(dict, skipInternal = false) : []

Alias: Keys

Returns array of keys from dictionary or object.

DictKeys Parameters

dict : Dict?

skipInternal : Boolean = false
True to skip keys starting with ‘$’ or internal properties.

DictKeys Examples

var ok = { A=1, B=2 }.DictKeys() == ['A', 'B'];
var ok = Date(1, 1, 1).DictKeys() == ['Year', 'Month', 'Day', 'DayOfWeek', 'DayOfYear'];

DictMerge(dict, dict1OrKey1, dict2OrValue1?, …) : Dict?

Merges key-value pairs or other dictionaries to one dictionary.
Updates source dict in place if possible, otherwise returns new dictionary.

DictMerge Parameters

dict : Dict?

dict1OrKey1 : ?

dict2OrValue1? : ?

? : ?

DictMerge Examples

var ok = { A=1 }.DictMerge('B', 2) == { A=1, B=2 };
var ok = { A=1 }.DictMerge({ B=2 }) == { A=1, B=2 };
var ok = { A=1 }.DictMerge('B', 2, { C=3 }) == { A=1, B=2, C=3 };

DictRemove(dict, key1OrArray1, …) : Dict?

Removes specified keys from dictionary.
Updates source dict in place if possible, otherwise returns new dictionary.

DictRemove Parameters

dict : Dict?

key1OrArray1 : ?

? : ?

DictRemove Examples

var ok = { A=1, B=2 }.DictRemove('B', 'A') == {};
var ok = { A=1, B=2 }.DictRemove(['A', 'B']) == {};
var ok = { A=1, B=2, C=3 }.DictRemove(['A', 'B'], 'C') == {};
var ok = { A=1, B=2 }.DictRemove('C', 'B') == { A=1 };

DictUnion(dict1, dict2, mergeArrays = false) : Dict?

Performs a deep merge of two dictionaries.
Updates dict1 in place if possible, otherwise returns new dictionary.

DictUnion Parameters

dict1 : Dict?

dict2 : Dict?

mergeArrays : Boolean = false

DictValues(dict, skipInternal = false) : []

Alias: Values

Returns array of values from dictionary or object.

DictValues Parameters

dict : Dict?

skipInternal : Boolean = false
True to skip keys starting with ‘$’ or internal properties.

DictValues Examples

var ok = { A=1, B=2 }.DictValues() == [1, 2];
var ok = Date(1, 1, 1).DictValues() == [1, 1, 1, 1, 1];

Leave a Comment

Your email address will not be published. Required fields are marked *