I'm reading Drools 6.4.0 documentation. I'm not sure to have understood the difference between contains
and memberof
operators: both work with collections and it seems that the only difference is that contains
expect the contained object on the right side while memberof
expect it on the left side, so they would be equivalent but I'm afraid I'm missing something.
This exemple is taken from Laune's answer to : Drools: Match local string from array in LHS of rule
rule "ruleY"
when
Data( $los: listOfStrings )
MyObject( string memberOf $los )
then
//do stuff
end
rule "ruleY"
when
MyObject( $s: string )
Data( listOfStrings contains $s )
then
//do stuff
end
They are complementary. Use the one or the other depending of the data you are having and the most logical way to express things.