Skip to main content
gamedev.net
🔒 Locked

[java] Switch case, multiple instances

Started by Arch@on Oct 13, 2002 at 12:03 PM 2 replies 200+ views
Original Post
Arch@on
Arch@on
This is just a minor thing, focusing on the look of the code. I''m trying to get multiple case instances to work. This is what I used before, but now its useless case ''a'', ''A'': break; But it fails me. I googled and found this method case ''a'': ''A'': but it fails me too. So how do you do it?
Sphet
Sphet

  
switch (someValue)
{
case ''A'':
case ''a'':
funcForA();
break;
case ''B'':
case ''b'':
funcForB();
break;
default:
funcForDefaultChar();
break;
}



Of course, you could also do this for characters:


  
switch (to_upper(someValue))
{
case ''A'':
funcForA();
break;
case ''B'':
funcForB();
break;
...
}



but you asked about multiple cases, not how to have only one case per upper and lower case characters.
Arch@on
Arch@on
Hey, thanks. That was awesome. I did not know about the uppercase working on lower case. I thought it was case sensitive.
kordova
kordova
It is case sensitive!
see the line in the second box:

switch (to_upper(someValue))

converting all to upper case

Topic Locked

This topic has been locked by a moderator. New replies are not allowed.

Sign in to reply to this topic.