0

Considering the code:

print( 1==2<3, (1==2)<3, 1==(2<3) )
False True True

I don't understand why the first expression 1==2<3 is evaluated to False. Precedence of <and == is the same and I guessed that in such a case expression is evaluated from left to right. But obviously, this is not the case.

Note that an equivalent C program evaluates all the three expressions to True.

Nicolas Rougier
  • 670
  • 7
  • 15

0 Answers0