Multiple Rule Variables – BAL vs IRL
The way multiple rule variables are declared and instantiated in working memory varies between the BAL and IRL.Business Action Language(BAL):
Suppose if we assign ‘Customer’ class instance to a multiple variables using definitions of a rule they are treated as two different instances.definitions
set ‘customer1’ to Customer;set ‘customer2’ to Customer;
Here customer1 and customer2 are treated as two different instances of class Customer and can be acted on independently.
IRL:
If we consider the same example as above and define multiple variables in IRL as below:when {
customer1: carrental.Customer();
customer2: carrental.Customer();
} then {
…
}
Here the variables customer1 and customer2 will refer to the same Customer instance in working memory and may create conflicts.To ensure it refers to different instances we need to add a test as below:
when {
customer1: carrental.Customer();
customer2: carrental.Customer(?this != customer1);
} then {
…}