skip to main content
Corticon Studio: Rule Modeling Guide : Filters and preconditions : Using collection operators in a filter
 

Try Corticon Now

Using collection operators in a filter

In the following examples, all Filter expressions use their default Filter-only behavior. As we discussed in the Rule Writing Techniques chapter, the logic expressed by the following three Rulesheets provides the same result:
Figure 182. A Condition/Action rule column with 2 Conditional rows
Figure 183. Rulesheet with one Condition row moved to Filters row
Figure 184. Rulesheet with Filter and Condition rows swapped
Even though expressions in the Filters section of the Rulesheet are evaluated before Conditions, the results are the same. This holds true for all rule expressions that do not involve collection operations (and therefore do not need to use aliases – we have used aliases in this example purely for convenience and brevity of expression): conditional statements, whether they are located in the Filters or Conditions sections, are AND'ed together. Order does not matter.
In other words, to use the logic from the preceding example:
If person.age > 40 AND person.skydiver = true, then person.riskRating = 'high'
Because it does not matter which conditional statement is executed first, we could have written the same logic as:
If person.skydiver = true AND person.age > 40, then person.riskRating = 'high'
This independence of order is similar to the commutative property of multiplication: 4 x 5 = 20 and 5 x 4 = 20. Aliases work perfectly well in a declarative language (like Corticon's) because regardless of the order of processing, the outcome is always the same.
* Location matters
* Multiple filters on collections