Actually, you still have the problem of locating the point where counter was last assigned a value. But in this case, I'd say the problem really is:Originally Posted by quzah
With shorter functions that do one thing and do it well, the problem of locating the declaration disappears, and declaring variables at the top is less problematic because the scope is already reduced.Originally Posted by \007
Agreed, unless there is a special reason to do so, the scope of i should not extend beyond the loop.Originally Posted by quzah
Prevention is better than cure.Originally Posted by Matticus