best-practice on for loop's condition
Posted
by guest
on Stack Overflow
See other posts from Stack Overflow
or by guest
Published on 2010-05-25T23:14:31Z
Indexed on
2010/05/25
23:21 UTC
Read the original article
Hit count: 210
what is considered best-practice in this case?
for (i=0; i<array.length(); ++i)
or
for (i=array.length(); i>0; --i)
assuming i don't want to iterate from a certain direction, but rather over the bare length of the array. also, i don't plan to alter the array's size in the loop body.
so, will the array.length()
become constant during compilation? if not, then the second approach should be the one to go for..
© Stack Overflow or respective owner