/ Published in: ActionScript

shows the basic structure of a switch statement. switches are useful when you want to respond to a series of possible values that a variable might have, without having to write a shitload of "if(blah blah){do blah}" code which, as we know soon ends up as curly bracket spaghetti!
Expand |
Embed | Plain Text
Copy this code and paste it in your HTML
/* |||||||||||||| SWITCH STATEMENT |||||||||||||||||| switches are useful when you want to respond to a series of possible values that a variable might have, without having to write a shitload of "if(blah blah){do blah}" code which, as we know soon ends up as curly bracket spaghetti. for example, if you had a variable called 'sizeofarse' which stored the girth of someone's buttocks and you wanted to respond accordingly you could use a switch, like so: switch(sizeofarse) { case "tiny": // do some tiny arse related stuff break; case "medium": // do some medium-sized arse related stuff break; case "huge": // do some huge arse related stuff break; } OK - got that. now for the real thing! ||||||||||||||||||||||||||||||||||||||||||||||||||| */ //begin switch switch() { // all possible 'cases' go below here //first case case "": // do first case stuff break; // second case case "": // do second case stuff break; // etc... etc... add as many more 'cases' as needed // all possible 'cases' go above here } // end switch
Comments
