Open main menu
Home
Random
Recent changes
Special pages
Community portal
Preferences
About Wikipedia
Disclaimers
Incubator escapee wiki
Search
User menu
Talk
Dark mode
Contributions
Create account
Log in
Editing
Logical disjunction
(section)
Warning:
You are not logged in. Your IP address will be publicly visible if you make any edits. If you
log in
or
create an account
, your edits will be attributed to your username, along with other benefits.
Anti-spam check. Do
not
fill this in!
===Logical operation=== Many languages distinguish between bitwise and logical disjunction by providing two distinct operators; in languages following [[C (programming language)|C]], [[bitwise disjunction]] is performed with the single pipe operator (<code>|</code>), and logical disjunction with the double pipe (<code>||</code>) operator. Logical disjunction is usually [[Short-circuit evaluation|short-circuited]]; that is, if the first (left) operand evaluates to <code>true</code>, then the second (right) operand is not evaluated. The logical disjunction operator thus usually constitutes a [[sequence point]]. {{anchor|parallel-or}}In a parallel (concurrent) language, it is possible to short-circuit both sides: they are evaluated in parallel, and if one terminates with value true, the other is interrupted. This operator is thus called the ''parallel or''. Although the type of a logical disjunction expression is Boolean in most languages (and thus can only have the value <code>true</code> or <code>false</code>), in some languages (such as [[Python programming language|Python]] and [[JavaScript]]), the logical disjunction operator returns one of its operands: the first operand if it evaluates to a true value, and the second operand otherwise.<ref>{{cite web |title=Python 3.12.1 Documentation - The Python Language Reference - 6.11 Boolean operations |url=https://docs.python.org/3/reference/expressions.html#boolean-operations |access-date=25 Dec 2023}}</ref><ref>{{cite web |title=JavaScript References - Expressions & Operators - Logical AND (&&) |date=25 September 2023 |url=https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Operators/Logical_AND |access-date=25 Dec 2023}}</ref> This allows it to fulfill the role of the [[Elvis operator]].
Edit summary
(Briefly describe your changes)
By publishing changes, you agree to the
Terms of Use
, and you irrevocably agree to release your contribution under the
CC BY-SA 4.0 License
and the
GFDL
. You agree that a hyperlink or URL is sufficient attribution under the Creative Commons license.
Cancel
Editing help
(opens in new window)