array.set_at Function |
The array.set_at function modifies the data stored at a specified index in the array.
Alchemy arrays use zero-based indexing and expand dynamically.
array.set_at(ident, idx, expr);
ident | An array identifier |
idx | The index of ident to modify |
expr | An expression to place in the array at the specified index |
The following example creates a new array initialized with a single element.
We then set the second element (index 1) to null and print the array.
Lastly we set the third element (index 2) to a new two-element array, again printing the array.
$arr = array.new(1); array.set_at($arr, 1, null); PRINT $arr; /* [1,(null)] */ array.set_at($arr, 2, array.new("array", "element")); PRINT $arr; /* [1,(null),[array,element]] */
array.add - add an element to the tail of an array
array.new - create a new array
array.pop - remove and return the element at the head of the array
array.range - return a sub-array from a specified array
array.get_at - retrieve the data at a specified index of an array
length - get the number of elements in an array