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?
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.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With