Builder (keys & values)
Last updated
Last updated
[data/dictionary/Builder (keys & values)]
Builds a dictionary based on matching arrays of keys and values. Items are constructed from the same indices of the input arrays.
If the array received by keys
contains duplicates, only the last precedent is taken into effect - the other corresponding values are discarded.
If the item counts of the input arrays differ, the out-of-bounds items are ignored.
Example A:
[ "first", "third", "fifth" ]@0 received via keys
[ 1, 3, 5 ]@0 received via values
dict
sends { "first": 1, "third": 3, "fifth": 5 }@0
Example B:
[ "first", "third", "fifth" ]@0 received via keys
[ 1, 3 ]@0 received via values
dict
sends { "first": 1, "third": 3 }@0
Example C:
[ "first", "first", "fifth" ]@0 received via keys
[ 1, 3, 5 ]@0 received via values
dict
sends { "first": 3, "fifth": 5 }@0
More: https://github.com/Cranq-io/cranq-tutorials/tree/main/reference/2_constructing_data/2_2_builders
Keywords: dictionary, dict, build, new, create, zip
keys: string[]
Receives the keys to construct the dictionary from. Example: ["first","third","fifth"]
values: any[]
Receives the values to construct the dictionary from. Example: [1, 3, 5]
dict: {string: any[][number]}
Sends the resulting dictionary. Example: { "first": 1, "third": 3, "fifth": 5 }