Skip to content

Contains

PeerHeer edited this page Dec 31, 2019 · 7 revisions

Description

The listutils:contains function checks if a list contains an element.

Usage

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.

Comparison functions

Various comparison functions can be used to match elements. For more about comparison functions, see the Comparison Functions page.

Errors

Errors that display when executing the listutils:contains function as a player in debug mode.

Error Message
TBD TBD

Return values

Success

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.

Result

The result of the operation is stored in the $listutils.result listutils.out score. The result is always the same as the success.

Example

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:contains

This will return a result of 1 in the $listutils.result listutils.out score, since the list contains the string "Hello World!"

Clone this wiki locally