jeudi 12 mars 2015

Can I put code inside switch(), above or under case x {}


Assume:



switch ( test ) {

// Set some variables, call some functions ?
int var x = 1 ;
int var y = function(x) ;
//

case 1 :
// Process for test = 1
...
break;

case 5 :
// Process for test = 5
...
break;

default :
// Process for all other cases.
...

}


Is it 'legal' to execute that extra bit of code I added before the first case: ? I've never seen this in examples.




Aucun commentaire:

Enregistrer un commentaire