Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

coldfusion calling another case within a switch

I have a switch like thus (written in cfscript):

switch (something) {
  case "stuff":
    if(this eq that){
      writeDump("hello");
    } else { /* do other? */ }
    break;
  case "other":
    //do something else
    break;
}

In my else, I want to be able to tell it that I want the "other" case to be invoked. Is this possible? (I seem to remember doing this in other languages.)

like image 629
Jarede Avatar asked Apr 26 '26 19:04

Jarede


1 Answers

There is no GOTO construct in CF, no. And that's pretty much what you're asking for.

If your switch is really as simple as you indicate, and you want to fall through to the NEXT case when the condition is false, what you could do is to have the break statement in the true branch of the if clause, and have no break statement in the false branch. Then when the false branch runs, processing will not exit the case when it's done; it'll fall through to the next case.

like image 156
Adam Cameron Avatar answered Apr 29 '26 15:04

Adam Cameron