条件の組み合わせ
グループに条件を適用して、ネストされたグループをテストすることができます。
論理演算子を使用して、ルールの 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 になります。
- 顧客は 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;