where (test)

The where <test> construct matches objects against tests.

Purpose

This construct tests that an object meets a condition.

Syntax

where <test>[,]*

Description

In the definitions part of a rule, you can use one or more where clauses with the set construct. Each set construct must end with a semicolon (;).

In a where construct, an implicit variable that refers to the current instance of the object is automatically declared. In the test, you can refer to instances of the variable as this <object type>, or each <object type> if they are part of a collection.

Example

The following example shows the definitions part of a rule that defines the local variable ‘expensive purchases’ as a collection of purchases whose price is greater than 100. The implicit variable each item is used in the where clause to refer to each purchase event in the collection.

definitions
    set 'expensive purchases' to all purchase events
        where the amount of each purchase event is more than 100;