Declarations¶
RuLa has two kinds of variables: instance variables, introduced through declarations, and value variables, introduced with := inside the assignment part of a rule. This page covers instance variables. For value variables, see Variables.
A declaration does two things at once: it matches one or more instances from the case (a Person, Entity, Contract, etc.) and it defines an instance variable — a short name you can use throughout the rest of the rule to refer to that instance and access its information fields. Each additional declaration matches one more instance, so p is Person and c is Contract together match one person and one contract.
You need to declare an instance variable before you can use it — an undeclared variable is unknown in RuLa.
The Impact of a Declaration¶
How you formulate a declaration has an impact on what a rule will be about. If, on a document, you declare these instance variables
that document will need to contain one contract and one person.
Alternatively, if you declare
that document will be about exactly one person. In a case that involves not one but three people, the system will require this document three times: once for each person in the case.
However, if you declare
on a document, that document can contain all three people in the case. It will only be required once.