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

should not use i in the inner loop, because the top-level loop also uses i #90

Merged
merged 1 commit into from
Mar 16, 2015

Conversation

yihui
Copy link
Contributor

@yihui yihui commented Mar 15, 2015

e.g. when data.evals.length == 1, i will be 1 by the end of this loop due to i++; then i will become 2 due to i++ from the outer loop, and the outer loop will exit early

here is a simplified minimal example, in which we expect i to be printed twice in the outer loop:

for (var i = 0; i < 2; i++) {
  console.log('outer loop i = ' + i);
  for (var i = 0; i < 1; i++) {
  }
  console.log('inner loop i = ' + i);
}
// outer loop i = 0
// inner loop i = 1
// i = 2 now

fixes rstudio/DT#25

…ses i

e.g. when data.evals.length == 1, i will be 1 by the end of this loop due to i++; then i will become 2 due to i++ from the outer loop, and the outer loop will exit early

here is a simplified minimal example, in which we expect i to be printed twice in the outer loop:

```js
for (var i = 0; i < 2; i++) {
  console.log('outer loop i = ' + i);
  for (var i = 0; i < 1; i++) {
  }
  console.log('inner loop i = ' + i);
}
// outer loop i = 0
// inner loop i = 1
// i = 2 now
```

fixes rstudio/DT#25
jjallaire added a commit that referenced this pull request Mar 16, 2015
should not use i in the inner loop, because the top-level loop also uses i
@jjallaire jjallaire merged commit 2cafa70 into ramnathv:master Mar 16, 2015
@yihui yihui deleted the bugfix/wrong-i branch March 16, 2015 15:26
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

strange interaction of htmlwidget packages
2 participants