Adding clarity to switch statements: a humble PHP feature proposal
shinyplasticbag.posterous.com
shinyplasticbag.posterous.com
"Oh you mean it just keeps going until you break? Okay, duly noted."
Fall through switch is quite useful, and if you really wanted an if-else, you'd use one, right?!
given($cat_macro){
when(/OH HAI/){
say "ceiling cat is watching you switch statements";
}
when(/OH NOES/){
die "FAIL";
}
default {
say "<picture of a walrus with a bucket>";
}
}
Pretty easy to follow the control flow, even when they aren't oneliners.next;
have:
// Continue through next case
The best part is that it's built into the language!!
Is there any reason why keeping things simple is not an option? The number of possible outcomes in a switch case can often be so many that falling through would just be the route to complicated and difficult to manage code.