Availability
This routine is available starting with katl-commons 2.5.7.
Syntax
arrayFind(arrayName, element)
Description
Finds an element inside the collection and returns its index. If the element is not found, it returns -1.Alias
arrayFind(arrayName, element)
Parameters
Parameter name | Type | Required | Description |
---|---|---|---|
arrayName | array | Yes | The array. |
element | type of array element | Yes | The element to find in the array. |
Return Type
number
Related routine
Related routine: arrayFindBinary() - but your array must be sorted prior to that. This routine is for general use. Binary search should be used only for sorted arrays.
Example
return arrayFind(usersInGroups({"jira-users"}), "admin");
The result of the routine is the index of the searched element in the array returned by usersInGroups.
If the array contains duplicates, the routine returns the index of the first occurrence of the searched element.
See also