0

How to perform something like this without using a bunch of if-else statements?:

char value;

switch (value)
{
    case 'a'..'p':
        do1();
        break;
    case 'q'..'z':
        do2();
        break;
    case 'き'..'ぴ':
        do3();
        break;
    case '似'..'光':
        do4();
        break;
    case 'ж'..'ф':
        do5();
        break;
    //... And many, many other ranges
}
Paul
  • 25,812
  • 38
  • 124
  • 247
  • Probably you need manually get group number and then switch on group number. – Valentin Mar 06 '16 at 22:37
  • you could create a class that includes the range and desired behavior then create a list of them, iterate them until you find one where the range matches and then do the desired behavior. – juharr Mar 06 '16 at 22:38
  • @juharr: Of course, I could create an infrastructure to do things in a "convenient" way, but was wondering about built-in capabilities. It seems that there are none of them and I will have to create an infrastructure. – Paul Mar 06 '16 at 22:41

0 Answers0