Link Search Menu Expand Document


Returns the first element in the given array for which the given function returns something other than 0. The <function> parameter must be included.


ARRAY_FIRST(<function>, <array>)


Parameter Description Supported input types
<function> A Lambda function used to check elements in the array Any Lambda function
<array> The array evaluated by the function Any array

Return Type

ARRAY of the same type as the input array


The following example returns the first value in the levels array greater than 2:

	ARRAY_FIRST(x -> x > 2, [ 1, 2, 3, 9 ]) AS levels;

Returns: 3

In the example below, the third index is returned because it is the first that evaluates to esimpson.

    ARRAY_FIRST(x, y -> y = 'esimpson', [ 1, 2, 3, 9 ], [ 'steven70', 'sabrina21', 'esimpson', 'kennethpark' ]) AS usernames;

Returns: 3