Remove the elements which are null from the array.
1 array.clearNulls
<array.clearNulls name='name'>
<array /> ?
</array.clearNulls>
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 can be passed as an argument of the function. |
Returns | |
---|---|
Type | Description |
array | Returns the updated list. |
Example
Remove all null elements from an array.
Copy
<xsql-script name='array_clearNulls'> <body> <array name='cities'> <string>Barcelona</string> <string>Paris</string> <null /> <string>Roma</string> <null /> </array> <!-- size: 5 --> <println>size: <array.size name='cities' /></println> <array.clearNulls name='cities' /> <!-- size: 3 --> <println>size: <array.size name='cities' /></println> </body> </xsql-script>
The result is:
Copy
size: 5 size: 3