Logical Operators
Operators for combining boolean expressions.
And
Returns true only if ALL conditions are true.
| Property | Value |
|---|---|
| Category | Logical Operators |
| Min Arguments | 2 |
| Returns | boolean |
Arguments:
| # | Name | Type | Description |
|---|---|---|---|
| 0+ | Boolean Expression | boolean | Conditions to evaluate |
Description: All statements must be true for the expression to evaluate as true.
Example:
And(IsActive, IsVerified) → true only if both are true
And(Amount > 0, Amount < 10000, IsApproved) → all three must be true
Truth Table:
| A | B | And(A, B) |
|---|---|---|
| true | true | true |
| true | false | false |
| false | true | false |
| false | false | false |
Or
Returns true if ANY condition is true.
| Property | Value |
|---|---|
| Category | Logical Operators |
| Min Arguments | 2 |
| Returns | boolean |
Arguments:
| # | Name | Type | Description |
|---|---|---|---|
| 0+ | Boolean Expression | boolean | Conditions to evaluate |
Description: At least one statement must be true for the expression to evaluate as true.
Example:
Or(IsAdmin, IsOwner) → true if either is true
Or(Status = "New", Status = "Pending") → true for either status
Truth Table:
| A | B | Or(A, B) |
|---|---|---|
| true | true | true |
| true | false | true |
| false | true | true |
| false | false | false |
Combining Logical Operators
You can combine And and Or operators to create complex conditions:
Example - Multiple Conditions:
And(
Or(IsAdmin, IsManager),
IsActive,
Not Null(Email)
)
This returns true if:
- User is either an admin OR a manager, AND
- User is active, AND
- User has an email address
Example - Business Rule:
Or(
And(CustomerTier = "Gold", OrderAmount >= 100),
And(CustomerTier = "Platinum", OrderAmount >= 50),
IsVIP
)
This returns true if:
- Customer is Gold tier with order >= $100, OR
- Customer is Platinum tier with order >= $50, OR
- Customer is a VIP
Best Practices
Use Parentheses for Clarity: When combining multiple operators, use parentheses to make the evaluation order clear.
Short-Circuit Evaluation: Both And and Or use short-circuit evaluation—if the result is determined by the first condition(s), subsequent conditions may not be evaluated.
Keep Conditions Readable: Break complex conditions into multiple lines or use intermediate variables for better readability.