Reference > Rule Language > Definitions > Matching an Object

A variable can be used to match an object of a specific type. The type of the variable is determined by the type of the object to match.

Remarks

An optional where construct can be used to match objects against predicates prior to assign the variable. For more information, see The where Construct.

You can also specify where the rule engine will find the matching objects. For more information, see The in <collection> Construct.

Example 1

This example shows how to declare the a senior gold customer variable, initialized to a customer who is a gold member and at least 60 years old.

 definitions 
   set 'a senior gold customer' to a Customer
       where all the following conditions are true:
           the category of this Customer is gold
           the age of this Customer is at least 60;

Example 2

This example demonstrates how to declare the free item variable, initialized to an item that costs at most $5, from the shopping cart of a customer.

 definitions 
   set 'free item' to an Item in the items of the Shopping Cart
       where the price of this Item is at most $5;