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

fix an error in loops.md #387

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 4 additions & 1 deletion src/guide/loops.md
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,10 @@ Loops can skip to the next iteration using the `continue` keyword. For example,
let mut i = 0

while (i < 10) {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think it might be better if we use a for loop here.

for (let mut i = 0; i <= 10; i += 1) {
  if (i % 2 == 0) continue;
  print(i)
}

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah, definitely!

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Therefore this code snippet should be moved into for loop section.

So feel free to close my PR and make your own changes, or make changes here.

I do not feel experienced enough to change the structure of this documentation.

if (i % 2 == 0) continue
if (i % 2 == 0) {
i += 1
continue
}
print(i)
i += 1
}
Expand Down