Hacker Newsnew | past | comments | ask | show | jobs | submitlogin

Neither counter nor idx strike me as an improvement over i.

If you want to be descriptive, name the purpose of the loop variable. If it's an array of foos or an array named foo, then use something like fooIx. Then when you loop over an array of bars, use something like barIx. If you're counting retries, call it retryIx or retryCt (or something that describes what you're retrying, like loginAttemptIx).

Depending on the context, i may be fine. However, a single-character name like that is bound to be reused, which is a bad smell.



Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: