Find the first occurrence of the object passed as an argument, checking the equality of objects
using the method 'equals'.
1 array.indexOf
<array.indexOf name='name'>
<value /> !
</array.indexOf>
Attributes | |||||
---|---|---|---|---|---|
Name | Type | Required | Default | Description | |
Aname | string | Name of the variable of the array type. |
Arguments | |||||
---|---|---|---|---|---|
Name | Type | Required | Unique | Nullable | Description |
Evalue | object | The object you want to search. |
Returns | |
---|---|
Type | Description |
Integer | Returns the index of the first occurrence of the object in the list; returns -1 if the object is not found. |
See also
http://docs.oracle.com/javase/7/docs/api/java/util/ArrayList.html#indexOf(java.lang.Object)
Example
Find the first position where the object is located.
Copy
<xsql-script name='array_indexOf'> <body> <array name='cities'> <string>Barcelona</string> <string>Paris</string> <string>Roma</string> </array> <!-- indexOf element: 1 --> <println>indexOf element: <array.indexOf name='cities'><string>Paris</string></array.indexOf></println> </body> </xsql-script>
The result is:
Copy
indexOf element: 1