Alternative – Allow multiple action possibilities

General

With the alternative block you can specify several nested alternative patterns. The alternative decides for one case match which it inserts into the current match tree, ignoring other possible matches by other cases.

Example code:

1  rule createProductFamilyNode{
2   
3    child:Product;
4    
5    alternative{
//specifies nested patterns ProductFamilyNodeNotYetExists and ProductFamilyNodeDoesExist
6    
7       ProductFamilyNodeNotYetExists{
8          negative {...}
9          modify {
10            newnode:ProductFamily -:IsFamilyOf->child;
11               eval{
12                  newnode.name = child.family;
13               }
14         }
15      }
16      ProductFamilyNodeDoesExist{
16         parent:ProductFamily;
17         if {parent.name == child.family;}
18         negative {...}
19         modify{
20            parent -:IsFamilyOf->child;
21         }
22      }
23   }
24 }

This code example can be found in our Soley Studio Tutorial.

How to use it:

More examples can be found in the Product Demo Analysis included in Soley Studio by default.

Was this article helpful?

Related Articles