Select to view content in your preferred language

Arcade: Add Equivalent to "Erase" Function for Dictionary

674
2
06-23-2023 11:32 AM
Status: Open
jcarlson
MVP Esteemed Contributor

With an array, I can erase items selectively using Erase:

var a = ['GIS', 'is', 'sorta', 'cool']

Erase(a, 2)

a

>> ['GIS', 'is', 'cool']

As far as I can tell, there is no equivalent way of doing this with a dictionary! I can manipulate the values of a dictionary, even set them to null, but I can't seem to just drop one of the keys.

I'd love if Erase could take a dict and a key as parameters.

2 Comments
CMV_Erik

I didn't notice this before. I assumed Pop would work, but it looks like that's also Array only

jcarlson

Update: you can use dict['key'] = null to accomplish this, so it can probably be closed.

But better would be a version of Pop that, when supplied with a dict and a key as parameters, executes the appropriate code for you.