Skip to main content
This topic is closed to new replies. Start a new post to keep the conversation going.

4 replies

WolfShade
Legend
Apr 26, 2013 1:46 PM UTC

Does CFLOOP:index add 1 to the index when the loop is completed??

For ex:

<cfoutput>


<cfloop index="idx" from="1" to="4">
Index = #idx#<br />
</cfloop>
Index now = #idx#
</cfoutput>

 

Will output:

Index = 1

Index = 2

Index = 3

Index = 4

Index now = 5

_

Translate
Participating Frequently
Apr 29, 2013 8:09 AM UTC

Yes it does, and this is standard behaviour (not just limited to CFML). It increments 'idx'... once it's greater than the upper 'to' limit, then the loop stops.

Translate
WolfShade
Legend
Apr 29, 2013 12:30 PM UTC

I just found it odd that it would increment one more time after the loop is done processing.  I guess not that it really matters.. just unexpected by myself.

^_^

Translate