Previous section To contents Next section

5.3 Logical operators

Logical operators are operators that operate with truth values. In Pike any value except zero is considered true. Logical operators are a very basic part of Pike. They can also decide which arguments to evaluate and which not to evaluate. Because of this the logical operators do not have any identifiers and can not be called as normal functions. There are four logical operators:

Function Syntax Returns
And a && b If a is false, a is returned and b is not evaluated. Otherwise, b is returned.
Or a || b If a is true, a is returned and b is not evaluated. Otherwise, b is returned.
Not ! a Returns 0 if a is true, 1 otherwise.
If-else a ? b : c If a is true, b is returned and c is not evaluated. Otherwise c is returned and b is not evaluated.


Previous section To contents Next section