skip to main content
Corticon Studio: Rule Modeling Guide : Collections : A basic collection operator
 

Try Corticon Now

A basic collection operator

As an example, let's use the ->size operator (see the Rule Language Guide for more about this operator). This operator returns the number of elements in the collection that it follows in a rule expression. Using the collection from Visualizing a Collection of Pilots:
aircraft.pilot -> size
returns the value of 2. In the expression:
aircraft.crewSize = aircraft.pilot -> size
crewSize (assumed to be an attribute of Aircraft) is assigned the value of 2.
Corticon Studio requires that all rules containing collection operators use unique aliases to represent the collections. Using aliases to represent collections is described in greater detail in this chapter. A more accurate expression of the rule above becomes:
plane.pilot -> size
or
plane.crewsize = plane.pilot -> size
where plane is an alias for the collection of pilots on aircraft.