Priority 9 operators

|x | yLogical OR operator

It is binary logical OR operator and has left-associativity.


Table of contents:


Logical OR operator

Logical OR operator

Logical OR operator performs logical OR operation on operands. Operands must be the bool class.

The result is the bool class.


bool result = true | true; // The result is true;

result = true | false; // The result is true;

result = false | true; // The result is true;

result = false | false; // The result is false;

Operand evaluation is not short-circuit evaluation. Both operands are always evaluated.


If operands return the proxy class, the entity of the proxy is automatically used. The result is the same as calling the Entity getter of the proxy class.


bool b = true;

bool b2 = false;

proxy pro = new proxy(b);

proxy pro2 = new proxy(b2);

bool b3 = pro2 | pro; // b3 is true.

Copyright © Rice All rights reserved.