条件の組み合わせ
グループに条件を適用し、ネストされたグループをテストすることができます。
論理演算子を使用して、ルールの if 部分の条件を結合できます。
次の if ステートメントには、1 つの条件が含まれています。
if the customer category is Gold
次の if ステートメントでは、論理演算子 and によって 2 つの条件がリンクされています。
if the category of the customer is Gold and the customer has been waiting longer than 5 minutes
and は or に優先する
論理演算子 and と or によって、ルールの if 部分の条件がリンクされる場合、and 演算子が or 演算子に優先します。
次の if ステートメントがあるとします。
if the customer is older than 60 or the customer is younger than 21 and the category of the customer is Student
このステートメントは、次の条件のいずれかが true の場合に true になります。
- 顧客は 60 歳を超えている
- 顧客は 21 歳未満であり、かつ顧客は学生である
複数の条件と括弧
括弧を使用して、論理演算子の優先順位を明確にすることができます。
次の if ステートメントでは、括弧によって年齢制限とカテゴリーがグループ化されます。
if the customer is older than 60 or (the customer is younger than 21 and the category of the customer is Student)
括弧を使用して、条件の解釈を変更することもできます。
次の if ステートメントでは、顧客が 60 歳を超えた学生か 21 歳未満の学生の場合に括弧内の条件が満たされます。
if (the customer is older than 60 or the customer is younger than 21) and the category of the customer is Student
同じ論理演算子を使用する複数の条件
条件をグループ化し、そのグループ内のすべての条件に対し、以下のステートメントを使用して同じ論理演算子を適用できます。
- all of the following conditions are true: このビジネス用語は、グループ内のすべての条件を論理演算子 and でリンクします。
- any of the following conditions is true: このビジネス用語は、グループ内のすべての条件を論理演算子 or でリンクします。
次のルールでは、両方の条件が true の場合にのみ、アクションが実行されます。
if all of the following conditions are true: - the category of the customer is Gold - a member of the Gold team is available then redirect the call to a member of the Gold team;
次の例では、顧客のカテゴリーがゴールドであるか、顧客の待ち時間が 5 分を超えた場合に、アクションが実行されます。
if any of the following conditions is true: - the category of the customer is Gold - the customer has been waiting longer than 5 minutes then redirect the call to a member of the Gold team;