This version is out of date, covering development from v9.5.0 to v9.7.3. It is maintained here only for inbound reference links from elsewhere. It is no longer actively updated.

Jump to the current version of aTbRef

Tinderbox v9 Icon

List/Set.any(loopVar, expressionStr)


Operator Type: 

Operator Scope of Action: 

Operator Purpose: 

Operator First Added: 

Operator Last Altered: 

Operator Uses Loop Variable Argument: 

 Function  [other Function type actions]

 List  [operators of similar scope]

 Query Boolean  [other Query Boolean operators]

 Baseline

 As at baseline

 [More on loop variable arguments]


List/Set.any(loopVar, expressionStr)

This is true if any loopVar in the list matches the expression.

$MyBoolean = $MyList.any(x,x>5) 

is true if any loopVar in $MyList is greater than 5.

The comparison may also be applied to literal lists:

"apple; pear; plum".any(x, x=="plum") 

is true because at least one element has the value "plum".

If the target list or set is empty, .any() always returns false, and .every() always returns true.

The loopVar is a user-set case-sensitive string. "x", "anItem", etc., are equally applicable. Similar to a loop variable in .each(x){}, the point of the loopVar value, is to set a reference variable for each list element. This can then be used in the code provided by the expressionStr argument. Using a number for loopVar, e.g. '1' or '42' is not recommended. Choose a value that makes sense for your own style of work

The expressionStr is any action code expression that is a test resolving to a Boolean true/false answer.

For example, to test if any item exactly matches the value stored in the $MyString of 'Some note':

$MyBoolean = $MyList.any(anItem, anItem == $MyString("Some Note")); 

Or, any list value that starts with the string 'Large':

$MyBoolean = $MyList.any(Z, Z.contains("^ large"));