0

Let's say I have an integer variable called X, I'd like to check if its value meets multiple conditions, I wonder if there's a way to write it like this (or similarly)

if (x == 1 || 2 || 3 || 4)

rather than using x again like

if (x == 1 || x == 2 || x == 3 || x == 4)

I just don't want to fill up my code if I have a lot of conditions required. Anyone knows the best way to shorten up the space for this kind of situations?

Axel1212
  • 143
  • 2
  • 10

0 Answers0