Hi
I read in more than one book that the logical operator AND && takes priority over the logical operator OR ||
So in this code fragment:
line 1 should be executed this way:
b change its value to 1 and it's equal to 1, c do the same, both expression are true so the whole expression is true. Since I'm using short-circuit operators, the last part
should not be executed. Right?
The line
should print "a=10 b=1 c=1 bool=true"
But this is what I get: "a=1 b=200 c=40 bool=true"
So he firstly check the code that is not supposed to be executed, then since the operators the part that should be executed is not.
And if I change the original line 1 to
I get the expected output. So it seems to me that he is evaluating the expression simply in the order they are written, with AND and OR having the same priority, just like + and - or * and /.
Where is the error?
Thank you in advance