| Reference > Rule Languages > ILOG Rule Language > IRL Keywords > in/!in (Predicates) |
in/!in (Predicates) |
PREVIOUS NEXT |
A predicate to test if a value belongs or does not belong to a collection. This keyword is used in any expression.
(1) [?var:] className (?var1 in|!in ?var2);
(2) [?var:] className (?var1 in|!in {? var1, var2, ..., varn});
The in keyword is used as a binary predicate in a condition to test whether the left operand is part of the right operand. The !in keyword does the negation of this test.
The right operand can be expressed in two ways:
java.util.Collection or be an array.
The tests are done with equals, as in Java collections.
rule InTestEnum
{
when {
?i: Integer(intValue() in {1, 2, 3});
}
then {
out.println("InTestEnum rule");
}
}
rule InTestCollection
{
when {
?i: Integer(intValue() in getValues());
}
then {
out.println("InTest rule");
}
}
with:
function int[] getValues()
{
int values = new int[2];
values[0] = 1;
values[1] = 2;
return values;
}
| Copyright © 1987-2008 ILOG S.A. All rights reserved. Legal terms. Documentation homepage. | PREVIOUS NEXT |