Hi! I want to add new values to the dictionary and haven't found a method that can help me.
var first = Dictionary('field1', 1, 'field2', 2)
If I want to add new key/value in the Dictionary, what can I use?
Solved! Go to Solution.
By assigning a value to a key, Arcade will overwrite an existing value or create a new key if it doesn't already exist.
var f = Dictionary('field1', 1, 'field2', 2)
// add new key/value pair
f['field3'] = 'hey'
// overwrite existing value
f['field1'] = 'overwrite!'
return f
PS - I'm assuming that's just a made-up sample, but don't use existing function names like first as variable names, it's just asking for trouble!
By assigning a value to a key, Arcade will overwrite an existing value or create a new key if it doesn't already exist.
var f = Dictionary('field1', 1, 'field2', 2)
// add new key/value pair
f['field3'] = 'hey'
// overwrite existing value
f['field1'] = 'overwrite!'
return f
PS - I'm assuming that's just a made-up sample, but don't use existing function names like first as variable names, it's just asking for trouble!