Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

complain when developer attempts to use iteration variable outside of a loop #82

Open
atsepkov opened this issue Sep 12, 2015 · 0 comments
Labels

Comments

@atsepkov
Copy link
Owner

The following anti-pattern is possible but should be discouraged:

for i in array:
    ...
doSomething(i)

Reasons for discouraging this pattern:

  1. for-in and native for will be off by 1 after loop terminates (this is implementation detail but a fix isn't worth it)
  2. this is illegal in all languages with proper scoping (i.e. perl) and will be illegal in JavaScript in the future (when let keyword is used for loop iterators)
  3. this pattern is discouraged even in languages where it's legal due to ambiguity
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

1 participant