multiple "OR"s

To shorten some code I was wondering if (a || b || c || d || e) would work, turns out it does work, but is a bad thing to do?
Assuming a, b, c, d, and e are all booleans or expressions returning booleans then... nope! Just don't use them excessively. :)

-Albatross
lol thanks, same applies to multiple &&'s i'm assuming?
you can do that with &&'s and ||'s for many pages if you need to depending on your program! I can't say if it's good or bad, sometimes it must be done.
I believe so! I'm not quite an expert on orthodox coding practices, but I have neither seen nor heard of any problems resulting from short chains of these. Possibly if the chains are too long and have no newlines in them, there could be a readability issue, but if you find a balance I don't think there will be any problems.

-Albatross
Thanks everyone
fwiw, multiple || or &&s in a single condition are a sign of overly complicated code. I find that I use || and && quite rarely.

If you find yourself in a situation where you have 5 conditions you need to chain like that, you're probably doing something wrong.
Also make sure no code within the || or && expressions has side effects, because with respect to those side effects they will act like conditionals. This is a side effect of the short-circuit evaluation of the expressions.
Topic archived. No new replies allowed.