,
fruit = "";
switch(fruit) {
case "Apple":
writeOutput("I like apples!");
break;
case "Orange": case "Citrus":
writeOutput("I like oranges!");
break;
case "Kiwi":
writeOutput("I like kiwi!");
break;
default:
writeOutput("Fruit, what fruit?");
break;
}
Expected Result: Fruit, what fruit?
<cfset fruit = "Orange">
<cfswitch expression="#fruit#">
<cfcase value="Apple">I like apples!</cfcase>
<cfcase value="Orange;Citrus" delimiters=";">I like oranges!</cfcase>
<cfcase value="Kiwi">I like kiwi!</cfcase>
<cfdefaultcase>Fruit, what fruit?</cfdefaultcase>
</cfswitch>
Expected Result: I like oranges!
Signup for cfbreak
to stay updated on the latest news from the ColdFusion / CFML community. One email, every friday.