Equality and Relational Operators


#1

When I try the following code

1 == 1 == false

The output I get is: FALSE

Is this because the equality operators are processed one at a time from left to right?

1==1 is processed first, returning TRUE.

Next, true==false is processed, returning FALSE


#2

Yep, that’s the reason, you can check it right here

From the above link:

When operators of equal precedence appear in the same expression, a rule must govern which is evaluated first. All binary operators except for the assignment operators are evaluated from left to right; assignment operators are evaluated right to left.


#3

This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.