<cfswitch>

Used with <cfcase> and <cfdefaultcase>. Evaluates a passed expression and passes control to the <cfcase> tag that matches the expression result. You can optionally code a <cfdefaultcase> tag, which receives control if there is no matching <cfcase> tag value.

This tag must have a body.

This tag is also supported within <cfscript>

Attribute Description
expression
string, required

Any CFML expression that yields a scalar value. CFML converts integers, real numbers, Booleans, and dates to numeric values.

<cfswitch
    expression=string
><!--- body ---></cfswitch>

Examples

```lucee+trycf this is from case 2 this is from case 2 this is from default part

<cfscript>
//Script example
    switch(1){
       case 1:
         result = 1;
         break;
       case 0:
         result = 0;
         break;
       default:
         result = "defaultCase";
    }
    writeDump(result);
</cfscript>

```

See also