Skip to main content
16 events
when toggle format what by license comment
Jul 26, 2021 at 12:50 comment added Scar In short, false && true || true is (false && true) || true
Feb 16, 2021 at 23:05 comment added Donnie @CollinAlpert The middle true is not evaluated, as the && short circuits.
Feb 11, 2021 at 13:15 comment added Bohemian @CollinAlpert anything || true is true. The operator && has greater precedence than || so it’s evaluated first, thus false && true || true becomes false || true, which is (as you found) true. It remains a fact that false && true is false.
Feb 11, 2021 at 9:16 comment added Collin Alpert I have a question regarding your statement that false && ... does not get evaluated because the result can only be false. Consider the statement false && true || true. This is evaluated to true.
May 11, 2020 at 22:08 comment added Bohemian @Kronen In this context, there is no difference. In order to be evaluated it must be executed. If something doesn’t need evaluating it isn’t executed.
May 11, 2020 at 20:37 comment added mckenzm @Kronen Execution may result in more than the evaluation, and produce a side effect, such as an exception or a delay, I will pay not relevant to this example.
S May 11, 2020 at 20:33 history edited VLAZ CC BY-SA 4.0
Small spelling fixes and improved the wording around "must be"
May 11, 2020 at 17:40 review Suggested edits
S May 11, 2020 at 20:33
May 11, 2020 at 11:37 comment added Kronen @mckenzm What is the difference between evaluated and executed?
Aug 5, 2019 at 4:28 comment added mckenzm Not only do they not evaluate the expression on the right hand side, the code is not executed for there to be anything to evaluate. This is a critical point of understanding if a side effect would otherwise be produced.
Oct 30, 2015 at 18:05 comment added A myth One thing I would like to highlight, | and & are binary operators,while && and || are conditional (logical) operators. | and & work on more than just booleans,while && and || work only on booleans.
Sep 4, 2015 at 10:26 comment added Stormcloud I'd just like to extend this answer a little. The &= operator is a shorthand for x = x & expression, and therefore is does NOT short circuit. The same is true of the |= operator.
Feb 16, 2013 at 19:56 history edited Bohemian CC BY-SA 3.0
added 2 characters in body
Jan 6, 2012 at 17:25 vote accept Aaron
Jan 6, 2012 at 15:16 history edited Bohemian CC BY-SA 3.0
added 787 characters in body
Jan 6, 2012 at 15:10 history answered Bohemian CC BY-SA 3.0