In test

Learn how to check if an element exists in a collection.

This test checks whether an element is in a collection. It works the same way as the contains test, but with the operands reversed.

You can use any collection type, including lists and maps. Keys are ignored when checking whether a map contains an element.

When comparing elements, this test uses the same equivalence rules as the equal operation to ensure consistency in how it determines whether two items are equal.

Syntax

This test has the following syntax:

/*<element>*/ is in /*<collection>*/

You can negate the test to verify the contrary:

/*<element>*/ is not in /*<collection>*/

Parameters

These are the supported parameters:

element
any

The element to search for in the collection.

collection

The collection to check.

Examples

Here is a simple example that checks whether an element is in a list:

"b" is in ["a", "b", "c"] // true

To negate the test, you can write:

"b" is not in ["a", "b", "c"] // false