Another Way to Continue in ColdFusion

Last Friday, I made a post about ColdFusion lacking a CFCONTINUE tag and showed a couple of ways to get around it. Thanks to erki for pointing out yet another method:

<cfloop from="1" to="10" index="i">
<cftry>
<cfif i eq 5>
<cfthrow type="continue">
</cfif>
This number will never be 5: #i#<br>
<cfcatch type="continue"><!--- ignore ---></cfcatch>
</cftry>
</cfloop>

3 Responses to Another Way to Continue in ColdFusion

  1. tjarko says:

    Just a tiny.. tiny comment… your cfthrow sets a type “continueE” (double e) en your catch catches only a type “continue”I subject strongly that the above will not work 😉

  2. Christian Murphy says:

    Have to say, throwing an exception and then swallowing it seems more obfuscatory than your earlier alternative (the simple cfif clause). Besides, throwing an exception during normal operation and ignoring it are CodeSmells *. Interesting hack, but if cfcontinue is supposed to make code more readable, I’m not sure this is a good alternative.[ * CodeSmell as defined on the c2 Wiki: http://c2.com/cgi/wiki?CodeSmell ]

  3. I just tried out your code — it doesn’t seem to work. I’d love to get this working. Maybe it’s the setup I have here — Mac os x (jaguar). Maybe it works for you on linux or winblows (errr.. I mean windows 🙂