A basic collection operator
- Last Updated: April 7, 2023
- 1 minute read
- Corticon.js
- Documentation
As an example, use the ->size
operator.
For more information, see Size of collection.
This operator returns the number of elements in the collection that it follows in a rule expression. Using the collection from Visualization 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.js Studio requires that all rules containing collection operators use unique aliases to represent the collections. How to use aliases to represent collections is described in greater detail in this chapter. A more accurate expression of the previous rule becomes:
plane.pilot -> size
or
plane.crewsize = plane.pilot -> size
where plane is an alias for the collection
of pilots on aircraft.