Can I use chained comparison operator syntax? [duplicate]

1 == 1 == 2  // this
true == 2    // becomes this
1 == 2       // which becomes this, and is false
2 > 1 == 1  // this
true == 1   // becomes this
1 == 1      // which becomes this, and is true

…and so on.

If you’re wondering about the conversion, you should do a search on the == operator, which uses the Abstract Equality Comparison Algorithm.

Leave a Comment