any of the following conditions is true
Purpose
The construct any of the following conditions are
true provides a more compact and convenient alternative to the logical operator or when you want to combine multiple conditions. The resulting
statement is considered true if at least one of the listed conditions is true.
Syntax
any of the following conditions is true:
(- <condition> )+ [,]
Description
This is equivalent to writing if <condition
1> or <condition 2> or ... <condition
n>. However, if you have a large number of conditions, using the any of the following conditions is true construct can make the
rule more readable.
The construct must be followed by a colon and one or more condition statements, each one on a separate line and preceded by a dash. Note that the dash that precedes each condition must be a ‘short dash’.
Optionally, you can add a comma after the last condition statement in the list to signify the end of the list of grouped. This will separate those conditions that form part of the construct from any additional condition statements that might follow.
Indentation in rules is for readability only; it does not influence the way the rule is processed.
Example
This example shows how to test if a customer is a Gold member or a senior customer.
if
any of the following conditions is true:
- the category of customer is Gold
- the age of customer is more than 60
then...
The following more complex example shows the use of a comma to mark the end of a group of conditions. In this example, the order must be over $50, the customer must be either a Gold customer or a senior customer, and the order must be shipping to NJ.
if
all of the following conditions are true:
- 'order total' is greater than $50
- any of the following conditions is true:
- the category of customer is Gold
- the age of customer is more than 60,
- 'shipping address' is in NJ
then...
Without the comma to mark the end of the any of the following
conditions are true block, the final condition ('shipping address' is in NJ) would be considered part of the previous group, and the rule
would be interpreted to mean that the order must be over $50 and (either the customer is a Gold
customer or a senior customer or the shipping address is in NJ).