Remove the first element of a variable of array type.
1 array.removeFirst
<array.removeFirst name='name'>
<array /> ?
</array.removeFirst>
Attributes | |||||
---|---|---|---|---|---|
Name | Type | Required | Default | Description | |
Aname | string | Name of the variable of array type. |
Arguments | |||||
---|---|---|---|---|---|
Name | Type | Required | Unique | Nullable | Description |
Earray | array | The array object can be referenced by name using the attribute name or it can be passed as an argument to the function. |
Returns | |
---|---|
Type | Description |
Object | The object which has been removed from the list. |
Example
Remove the first element of an array.
Copy
<xsql-script name='array_removeFirst_test1'> <body> <array name='cities'> <string>Barcelona</string> <string>Paris</string> <string>Roma</string> </array> <array.removeFirst name='cities' /> <println><cities/></println> </body> </xsql-script>
†he first element from the collection of cities, which is 'Barcelona', is removed. An alternative to erase the first string, less elegant but equally valid, would be:
Copy
<array.removeFirst/><cities/></array.removeFirst>
The result is:
Copy
Paris Roma