|| Operator

Language Items List

Definition:

Used to perform a logical disjunction on two expressions.

Syntax:

result = expr1 ||expr2

Details:

The double pipe operator is the boolean, or logical, equivalent of the Or operator.

The Truth table is the same as that for the OR Operator, as shown in the following table. Notice that the result bit evaluates to False (0) only when the bits in both expressions are False.


expr1 bit expr2 bit result bit


0 0 0

0 1 1

  1. 0 1

  1. 1 1

The difference between the operators is in how the expression is determined as True or False.

For ||, the second expression is only evaluated if the first is False. This means it is not yet known if the expression is True, the second part must be evaluated. For example, If a || b then True, if a or b independently are non-zero the result will be True, the result is not dependent on the bitwise OR of the two.

It is valid to combine a
typeof obj is objname with other expressions, as in: If TypeOf objRef Is Form || a = 1 Then Print true. The logical operators && and || give better results in cases such as this and are recommended over the bitwise operators in similar situations.

See Also:

Arithmetic Operators
Comparison Operators