arrays.index_to_int

Supported in:
arrays.index_to_int(array_of_inputs, index)

Description

Returns the value at a given index in an array as an integer.

The index is an integer value which represents the position of an element in the array. By default, the first element of an array has an index of 0, and the last element has an index of n-1, where n is the size of the array. Negative indexing allows accessing array elements relative to the end of the array. For example, an index of -1 refers to the last element in the array and an index of -2 refers to the second to last element in the array.

Param data types

ARRAY_STRINGS|ARRAY_INTS|ARRAY_FLOATS, INT

Return type

INT

Code samples

Example 1

This function call returns 0 when the value at the index is a non-numeric string.

arrays.index_to_int(["str0", "str1", "str2"], 1) = 0
Example 2

This function returns the element at index -1.

arrays.index_to_int(["44", "11", "22", "33"], 0-1) = 33
Example 3

Returns 0 for the out-of-bounds element.

arrays.index_to_int(["44", "11", "22", "33"], 5) = 0
Example 4

This function fetches the element from the float array at index 1.

arrays.index_to_int([1.100000, 1.200000, 1.300000], 1) = 1
Example 5

This function fetches the element from the int array at index 0.

arrays.index_to_int([1, 2, 3], 0) = 1