It looks like you're new here. If you want to get involved, click one of these buttons!
/* define an array of people (objects) with names */ <<set $arr to [{name:'alice'}, {name:'bob'}, {name:'casey'}]>> $arr[0].name /* Outputs "alice" */ /* do something to the array */ <<arraywidget $arr>> /* let's say the widget looks like */ <<widget "arraywidget">> <<for _i = 0; _i < $args.length; _i++>> <<print $args[_i].name>> <</for>> <</widget>>
<<widget "wordywidget">> <<for _i = 0; _i < $args.length; _i++>> <<set _person to $args[_i]>> <<print _person.name>> <</for>> <</widget>>
<<widget "borkedwidget">> <<for _i = 0; _i < $args.length; _i++>> <<print $args[_i]>> <</for>> <</widget>>which outputs "[object Object], [object Object], [object Object]", i.e. the entire array as one element of $args. (Since I didn't explicitly print the commas, I'm pretty sure this is the string representation of the outer array $arr.)
Comments
In your first example, you are incorrectly attempting to reference it as though it was the array you passed in. You needed to index its zeroth position, which yields the array you passed in, and then iterate over that. For example:
You know, I could have sworn I tried that already, but I must have mucked it up that time. Anyway, your snippet works just fine, so thank you kindly for the clarification!