Logical Operators
On this page:
And, And If Operators
Behavior: Evaluates two or more conditions, yielding true if both conditions are true, and false otherwise. Both the and and the and if operators will yield a logical value of true if and only if both of their operands are true. The and operator always fully evaluates both of its operands, while the and if operator only evaluates operand2 if operand1 is true. In the second example, the fullValidate() function will only be called if operation is equal to "test".
Parameters: Two or more conditions to test.
Syntax:
operand1 and if operand2
Syntax definitions for language elements follow these formatting guidelines:
- boldface: Indicates words and characters that must be typed exactly
- italic: Indicates expressions or other variable elements
- {} (curly braces): Indicate optional elements.
- [] (square brackets) separated by | (vertical pipes): Indicate alternative options where one or the other can be used, but not both.
Example syntax:
In this example, "open file" is required and must be typed exactly. "fileName" is a variable element; it is the path to and name of the file being opened. The following expression is optional and indicates why the file is being opened. If this expression is added, "for" is required and must be typed exactly. One of the following must be included, but only one, and they also must be typed exactly: "reading", "writing", "readwrite", "appending", or "updating".
Example:
if x > 7 and x < 12 then
Example:
if operation is "test" and if fullValidate(system) then
Or , Or If Operators
Behavior: Combines two conditions, yielding true if either one is true. Both the or and the or if operators will yield a logical value of true if either or both of their operands are true. The or operator always fully evaluates both of its operands, while the or if operator only evaluates operand2 if operand1 is false. In the second example, the search of file "N37" for "ruby" will only be performed if status is not equal to 99.
Syntax:
operand1 or operand2
operand1 or if operand2
Syntax definitions for language elements follow these formatting guidelines:
- boldface: Indicates words and characters that must be typed exactly
- italic: Indicates expressions or other variable elements
- {} (curly braces): Indicate optional elements.
- [] (square brackets) separated by | (vertical pipes): Indicate alternative options where one or the other can be used, but not both.
Example syntax:
In this example, "open file" is required and must be typed exactly. "fileName" is a variable element; it is the path to and name of the file being opened. The following expression is optional and indicates why the file is being opened. If this expression is added, "for" is required and must be typed exactly. One of the following must be included, but only one, and they also must be typed exactly: "reading", "writing", "readwrite", "appending", or "updating".
Example:
if x < 7 or x > 12 then
Example:
if status = 99 or if file "N37" contains "ruby" then
Not Operator
Behavior: Obtains the opposite of a true or false condition.
Syntax:
Syntax definitions for language elements follow these formatting guidelines:
- boldface: Indicates words and characters that must be typed exactly
- italic: Indicates expressions or other variable elements
- {} (curly braces): Indicate optional elements.
- [] (square brackets) separated by | (vertical pipes): Indicate alternative options where one or the other can be used, but not both.
Example syntax:
In this example, "open file" is required and must be typed exactly. "fileName" is a variable element; it is the path to and name of the file being opened. The following expression is optional and indicates why the file is being opened. If this expression is added, "for" is required and must be typed exactly. One of the following must be included, but only one, and they also must be typed exactly: "reading", "writing", "readwrite", "appending", or "updating".
Example:
if not showGreeting then ...