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

Make .enumerate() example self-explanatory #34880

Merged
merged 1 commit into from
Jul 21, 2016
Merged
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
14 changes: 7 additions & 7 deletions src/doc/book/loops.md
Original file line number Diff line number Diff line change
Expand Up @@ -105,19 +105,19 @@ When you need to keep track of how many times you already looped, you can use th
#### On ranges:

```rust
for (i, j) in (5..10).enumerate() {
println!("i = {} and j = {}", i, j);
for (index, value) in (5..10).enumerate() {
println!("index = {} and value = {}", index, value);
}
```

Outputs:

```text
i = 0 and j = 5
i = 1 and j = 6
i = 2 and j = 7
i = 3 and j = 8
i = 4 and j = 9
index = 0 and value = 5
index = 1 and value = 6
index = 2 and value = 7
index = 3 and value = 8
index = 4 and value = 9
```

Don't forget to add the parentheses around the range.
Expand Down