The OR
operator is used to evaluate two expressions. We can write a double pipe ||
to use the OR
operator. It will return either a True
or a False
based on the conditions.
expression1 || expression2
It returns a boolean value based on the given expressions.
Let's take a look at the truth table for OR
.
Expression 1 | Expression 2 | Result |
False | False | False |
False | True | True |
True | False | True |
True | True | True |
From the table above, we can conclude that if any one of the expressions is evaluated as True
, then the result will be True
.
Let's take a look at an example of this.
main::IO()main = doprint( 5<10 || 36<25 )
In the above code snippet:
True
while the second expression evaluates to False
, and the OR
operator returns True
according to the above table.