The OR operator is a Boolean operator that executes an operation or task if one or more values or operands are met. For example, 1 + 1 = 3 or 1 + 1 = 2 is true because 1 + 1 does equal 2 even though 1 + 1 does not equal 3. For languages or services that do not accept the word “or” as an operator, it is often replaced with the pipe symbol. An example of this instance is shown in the Perl code below.
use strict;if ((1 + 1 == 3) || (1 + 1 == 2)) { print “True\n”;} else { print “False\n”;}
In the example above, the double pipe ( || ) is the OR operator. Since one of the problems is true, running this script would return “True.”
Operator, Programming terms
Related information
- How to create a computer program.