Page 1 of 1

Switch Case jumping between two cases

Posted: Sun Sep 09, 2012 10:31 pm
by Live24x7
Hi

Is it possible to jump from one case to another ?
if so how?

I want to do something like this

Code: Select all

switch(situation){
          case 'a':
                 //..
          break;
          case 'b':
                if (condition x) goto case a
                if (condition y) goto case c
           break;
          case 'c':
                 //..
          break;
              
}
thanks a lot

Re: Switch Case jumping between two cases

Posted: Sun Sep 09, 2012 10:37 pm
by Christopher
No. Probably better to use ifs.

Re: Switch Case jumping between two cases

Posted: Sun Sep 09, 2012 11:42 pm
by Live24x7
thnks given that i had 16 cases to evaluate, i stayed with switchcase. Just defined functions for caseA and caseC and the code now looks like:

Code: Select all

switch(situation){
          case 'a':
                 caseA();
          break;
          case 'b':
                if (condition x) caseA();
                if (condition y) caseC()
           break;
          case 'c':
             caseC();
          break;
             
}