Which is better?
function blah() {
switch( $bob ) {
case 1:
return "this";
case 2:
return "that";
default:
return "other";
}
}
function blah() {
$retval = "";
switch( $bob ) {
case 1:
$retval = "this";
break;
case 2:
$retval = "that";
break;
default:
$retval = "other";
break;
}
return $retval;
}
In other words, is it good practice to exit out of a block (any
block... not just switch; if, for, while) prematurely as demon-
strated in the first example? Or should you do it as demon-
strated in the second example?
Chris