Click or drag to resize

array.set_at Function

Verizon Connect Logo
Print this page
Learn more about Verizon Connect GeoBase.
Get information about the latest release
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.

Syntax

Alchemy
array.set_at(ident, idx, expr);

Nomenclature

identAn array identifier
idx The index of ident to modify
exprAn expression to place in the array at the specified index

Example

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.

Alchemy
$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]] */

See Also

  • 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