-
Notifications
You must be signed in to change notification settings - Fork 0
Contains
The listutils:contains function checks if a list contains an element.
Input is given using the listutils:in storage:
| Field | Meaning |
|---|---|
List |
The list that could contain the element. |
Data |
The element that could occur in the list. |
After defining the input, run the function listutils:contains.
Various comparison functions can be used to match elements. For more about comparison functions, see the Comparison Functions page.
Errors that display when executing the listutils:contains function as a player in debug mode.
| Error | Message |
|---|---|
| TBD | TBD |
The success of the operation is stored in the $listutils.success listutils.out score. This score is 1 on success and 0 otherwise. Success will be 0 when the list does not contain the element.
The result of the operation is stored in the $listutils.result listutils.out score. The result is always the same as the success.
Take the example list ExampleList: ["foo", "Hello World!", "foo", "bar"] in the listutils:examples storage. We want to find out if it contains the string "Hello World!":
# Add List to the input.
data modify storage listutils:in List set from storage listutils:examples ExampleList
# Add Data to the input.
data modify storage listutils:in Data set value "Hello World!"
# Call the function.
function listutils:containsThis will return a result of 1 in the $listutils.result listutils.out score, since the list contains the string "Hello World!"