File tree Expand file tree Collapse file tree 2 files changed +3
-3
lines changed Expand file tree Collapse file tree 2 files changed +3
-3
lines changed Original file line number Diff line number Diff line change @@ -45,7 +45,7 @@ int main() {
4545 bool condition1 = false ;
4646 bool condition2 = true ;
4747 print ( alwaysTrue && condition1 && condition2 );
48- print ( alwaysTrue || condition1 && condition2 ); // Q: Why does operator precedence render this expression useless ?
48+ print ( alwaysTrue || condition1 && condition2 ); // Q: Is this expression useful ?
4949 print ( alwaysTrue && condition1 || condition2 );
5050 print (condition1 != condition1); // Q: What is the difference between this and the following expression?
5151 print (condition2 = !condition2);
Original file line number Diff line number Diff line change @@ -45,8 +45,8 @@ int main() {
4545 bool condition1 = false ;
4646 bool condition2 = true ;
4747 print ( alwaysTrue && condition1 && condition2 );
48- print ( alwaysTrue || condition1 && condition2 ); // Q: Why does operator precedence render this expression useless ?
49- print ( alwaysTrue && condition1 || condition2 ); // A: "true || " is evaluated last. The expression therefore is always true.
48+ print ( alwaysTrue || condition1 && condition2 ); // Q: Is this expressing useful ?
49+ print ( alwaysTrue && condition1 || condition2 ); // A: Not really. Since we use "true ||", it is always true.
5050 print (condition1 != condition1); // Q: What is the difference between this and the following expression?
5151 print (condition2 = !condition2); // A: The first is a comparison, the second a negation with subsequent assignment
5252 print ( alwaysTrue && condition1 && condition2 );
You can’t perform that action at this time.
0 commit comments