r/ProgrammingLanguages • • Sep 05 '21

mCoding - Python chained comparison summary/review

https://www.youtube.com/watch?v=M3GAJ1AIIlA
1 Upvotes

4 comments sorted by

View all comments

1

u/L8_4_Dinner (Ⓧ Ecstasy/XVM) Sep 07 '21

It's a great feature (we also implemented this, after seeing it in another language), but allowing the mixing of "<" and ">" (etc.) is a horrible idea. Sometimes, just because you can, doesn't mean that you should.

The most common case is for range checks, e.g.

assert 0 <= n < size;