Select to view content in your preferred language

Improve Arcade Array

2832
5
02-28-2020 04:07 PM
Status: Implemented
Labels (1)
DuncanHornby
MVP Notable Contributor

I would like the Array object in Arcade to support functionality like push().  Being able to build lists of values when doing field calculations would be very useful.

5 Comments
jcarlson

Until a more direct solution like push() is incorporated, you can still accomplish what you describe. I regularly use Arcade to build an array for popups and field calculations. When you call an established array of length n, assigning a value to the array at index n + 1 will append the value to the end of the array.

var arr_index = 0
var arr = []

arr[arr_index] = 'red'
++arr_index

arr[arr_index] = 'yellow'
++arr_index

arr[arr_index] = 'blue'

return arr

---> ['red', 'yellow', 'blue']
DuncanHornby

Hi Josh,

That's really useful to know. I didn't know you could append to an array in that manner. I think this is more about me not knowing the intricacies of javascript!

Thanks for putting me on to this, I can certainly work with this technique.

Duncan

KevinMayall

Arcade now has a Push function.

KoryKramer
Status changed to: Implemented
DarrylKlassen1

Thanks for the Push function tip - reduces/simplifies my code!