"or" operator without repeating the left hand condition again

operators, programming-languages

Solution

Python does, kind of:

if x in [something, somethingelse]:
    ...

`in` simply checks whether an element occurs in a given list. Similarly, in Haskell:

if x `elem` [something, somethingelse] then ...

I suppose that this can be done in most languages that allow for expressions of list type.

Problem

Ever since I started programming properly using good old `VB6` and up until present day, I often still get burned (and just have) by this in programming: ``` if x == something or x == somethingelse ``` I often end up writing: ``` if x == something or somethingelse ``` Just out of pure interest, does any langauge/languages out there support this?

Original source