Chained inequality notation in programming languages

Posted by Davorin on Stack Overflow See other posts from Stack Overflow or by Davorin
Published on 2010-04-15T09:18:52Z Indexed on 2010/04/15 9:23 UTC
Read the original article Hit count: 291

Is there a programming language that supports chained notation a < b < c to be used instead of a < b and b < c in conditional statements?

Example:

  1. if ( 2 < x < 5 )
  2. if ( 2 < x && x < 5 )

First statementlooks better to me, it's easier to understand and the compiler could use transitivity property to warn about mistakes (e.g. 5 < x < 2 would give a warning).

© Stack Overflow or respective owner

Related posts about conditional

Related posts about programming-languages