Check if Collection Contains

Verb: contains

Checks whether a collection contains a specific item.

Collections are enumerable data structures that can be accessed using indexes and keys.

Syntax

contains --value(Variant) --collection(ICollection<Variant>) (Boolean)=value

Inputs

Script Designer Required AcceptedTypes Description
--value Item to Check Required Any Item that is checked in the collection.
--collection Collection Required ICollection<Any> Collection in which the item's existence is checked.

Outputs

Script Designer AcceptedTypes Description
value Contains Item Boolean Returns "True" if the collection contains the item or "False" if it does not.

Example

Checks if the collection contains the item "Ana".

defVar --name nameCollection --type Stack --innertype String --value "[Ana, Mary, Lucas, Victor]"
defVar --name collectionContains --type Boolean
contains --value Ana --collection "${nameCollection}" collectionContains=value
logMessage --message "${collectionContains}" --type "Info"
// The result of ${collectionContains} after execution is: True.

Remarks

In Item to Check, the inserted value must be of the same type (Text, Numeric, Boolean...) as the one specified for the Collection items.

See Also

  • Count Items
  • Get List Item
  • Remove Items from Collection