Ruby:
true == true == true
syntax error, unexpected tEQ
vs. JavaScript:
true == true == true
// => true
vs. C:
1 == 1 == 1
// => 1
Association direction, which controls the order of operators having their arguments evaluated, is not defined for the ==
method, same as for ===
, !=
, =~
and <=>
methods as well (all of which have the same precedence and form a separate precedence group exclusively).
Thus evaluation order in case of multiple operators from the list mentioned above being chained in a row should be set explicitly via either
parenthesis ()
:
(true == true) == true # => true
true == (true == true) # => true
or dot operator .
(can be omitted for the last equality check in a row):
true .== true == true # => true