I tried googling and failed.
Using C, I have an IF statement. I want to test a variable against two non-consecutive values.
Is it possible to do
if (state == 1 || 3)
Meaning if state is 1 or if state is 3.
Or does it have to be
if (state == 1 || state == 3)
I'm thinking the first actually means if state is 1, or 3, which means the test will always be true (if true or true).
Is there a way to write this without having to rewrite the variable name multiple times?
No, I don't want to use a case
/ switch
statement. I'm trying to type less.
See Question&Answers more detail:
os 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…