Element position
Syntax
$set.elementIndex($element)
Description
Returns the position of an element in a list, counting from 0. If the element is contained more than once, the position of the first occurrence is returned.
Parameters
Name | Type | Description | Mandatory | Default |
---|---|---|---|---|
set | Set | A set in which the position of an element is to be determined. | yes | |
element | Number/string/boolean/businss object/set | The element whose position is to be determined. | yes |
Return value
Type: Number
The index of the element's position in the set
. If the element occurs more than once, the index of the first occurrence is returned. If the element is not contained at all, -1 is returned.
Examples
Element is in the set 1 time
list(1, 2, 3, 4).elementIndex(2)
Output: 1
Element is in the set more than once
list(1, 2, 2, 2, 3, 4).elementIndex(2)
Output: 1
Element is not in the set
list(1, 2, 2, 2, 3, 4).elementIndex(8)
Output: -1