Combinações de Condições
Combine várias condições na parte if da regra.
É possível usar operadores lógicos para combinar condições na parte if.
A instrução a seguir contém uma condição:
if the customer category is Gold
Na instrução a seguir, o operador lógico and vincula duas condições:
if the category of the customer is Gold and the customer has been waiting longer than 5 minutes
Precedência de and sobre or
Quando os operadores lógicos and e or vinculam condições na parte if de uma regra, o operador and tem precedência sobre o operador or.
Considere a seguinte instrução if:
se the age of 'the customer' is more than 60 or the age of 'the customer' is less than 21 and the category of 'the customer' is Student
A instrução será true se uma das seguintes condições for true:
- O cliente tem mais de 60 anos
- O cliente tem menos de 21 anos e é estudante
Diversas Condições e Parênteses
É possível usar parênteses para esclarecer a precedência de operadores lógicos.
Na instrução a seguir, os parênteses agrupam um limite de idade com uma categoria:
se the age of 'the customer' is more than 60 or (the age of 'the customer' is less than 21 and the category of 'the customer' is Student)
Também é possível usar parênteses para alterar a interpretação das condições.
Na instrução a seguir, a condição entre parênteses será atendida se o cliente for um estudante com mais de 60 anos ou menos de 21 anos:
se (the age of 'the customer' is more than 60 or the age of 'the customer' is less than 21) and the category of 'the customer' is Student
Diversas Condições que Usam o mesmo Operador Lógico
É possível agrupar condições e aplicar o mesmo operador lógico a todas as condições no grupo usando entre estas instruções:
- all of the following conditions are true: Este termo de negócios vincula todas as condições no grupo ao operador lógico and.
- any of the following conditions is true: Este termo de negócios vincula todas as condições no grupo ao operador lógico or.
Na seguinte regra, a ação é executada apenas quando ambas as condições são true:
se all of the following conditions are true: - the category of the customer is Gold - there is at least one member in the members of 'the Gold team' então print "redirect the call to a member of the Gold team";
No seguinte exemplo, a ação será executada se a categoria do cliente for Ouro ou o se cliente estiver esperando há mais de cinco minutos:
se any of the following conditions is true: - the category of the customer is Gold - the waiting duration of 'the customer' in minutes is more than 5 então print "redirect the call to a member of the Gold team";