I received some code that has an outer loop and an inner loop that use
the same variable index name (which is horrid practice, but regardless
it sparked my curiosity).
Running this
#1
<cfscript>
for(i=0; i lte 10; i=i+1)
{
for(i=0; i lte 10; i=i+1)
{
writeoutput(i & "<br />");
}
}
</cfscript>
loops to 10 as I would expect, but this (which is like the block I got)
#2
<cfloop from="0" to="10" index="i">
<cfloop from="0" to="10" index="i">
<cfoutput>
#i#<br />
</cfoutput>
</cfloop>
</cfloop>
loops to 10 10 times (which happens to be the proper logic for the
application).
I am pretty sure it has to do with scoping, but in example #2 how
would you get to the outer loops version of i? caller.i is a no-go.
And Is this a bug or a feature?
(P.S. I am rewriting the problem block so it wont be an issue, I am
just curious)
--
~The cfml plug-in for eclipse~
http://cfeclipse.tigris.org
~open source xslt IDE~
http://treebeard.sourceforge.net
~open source XML database~
http://ashpool.sourceforge.net
[Todays Threads] [This Message] [Subscription] [Fast Unsubscribe] [User Settings] [Donations and Support]

