I have a switch statement set up, with 2 cases (a or v). I could have just done an OR, but decided to practice with switch statements.

So far i'm using it to select what letter they type in, then launch the next part of the program depending on the letter they chose. Thing is, if I do:

case 'a':

then if they type "A" it will go to the default. self explanatory. But I want to know, can I add the uppercase A to the same case? Ive tried

case 'a' || 'A':

but that doesnt work.
I dont really want to have

case 'a':
(code here)
case 'A':
(same code here)

etc, taking up lots of room.
Its most likely the simplest fix ever. I seem to ask the most stupid questions at the moment eheh..

thanks for help.

Edited by FriXionX: n/a

5 Years
Discussion Span
Last Post by jonsca

Just omit the break in the middle. Switch statements "fall through" until they reach a break;

case 'a':
case 'A': //do stuff here

Edited by jonsca: n/a

Votes + Comments
fast help, thanks.

hey, thanks!
I knew it was simple.. I'm so stupid sometimes.

This question has already been answered. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.