+ 2
For loop
is declaring a variable inside for loop good?
2 Answers
+ 10
There are better ways to avoid repeated initializations, by placing the declaration outside the for loop and initialising it in the loop if required, if this does not make a difference to what you originally intended to do. Performance-wise, the difference should usually be too subtle to notice, seeing that your compiler might optimize it for you anyways.
+ 1
no