On Tue, 23 Jul 2002, Javier Montserat wrote:
So refering back, i re-wrote the original example using the switch syntax...
switch (true) {
case doStep1():
case doStep2():
case doStep3():
error();
break;
default:
valid();
}
Each case expressions is evaluated, until one of them
is there a more programmatically elegant way of saying...
$isError = ;
function main() {
doStep1();
if (!$isError) {
doStep2();
}
if (!$isError) {
doStep3();
}
// etc. etc.
}
function doStep1() {
if ($something) {
$isError = 1;
}
}
For steps and sequences, I always use switches. Most commonly associated with the
action variable, it would look like this:
switch($action) {
default:
// what to show if no variable exists, or is set to a value
// that is not acceptable below
break;
case add_file:
//
So refering back, i re-wrote the original example using the switch syntax...
switch (true) {
case doStep1():
case doStep2():
case doStep3():
error();
break;
default:
valid();
}
Each case expressions is evaluated, until one of them evaluates to a value
equal (==) to the switch expression
4 matches
Mail list logo