Coldfusion Control Structures: Which IF does the else go to?

340 views Asked by At

In Java, the else statement goes to the closetest If statement.

so if you have a nested if statement:

if (expression) {

if(secExpression) {

}
else {
// goes with second expression
}
}

The else goes with the second if nested inside.

Where does the else go to in the Coldfusion control structure?

<cfif expression> 
   <cfif secExpression> 
   </cfif>
   <cfelse>
</cfif> 
1

There are 1 answers

0
Paŭlo Ebermann On BEST ANSWER

The nested-tag syntax makes it unambiguous: The <cfelse> has to be inside of the <cfif ...> ... </cfif> tag, so in your example the <cfelse> can only be related to the outer <cfif>.