Skip to content
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
13 changes: 13 additions & 0 deletions src/flow_control/for.md
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,19 @@ fn main() {
}
```

Just remember that even though you can compile the code when a>b, the loop gets
never executed.
```rust,editable
for i in 10..1{
println!("fizzbuzz");
}
```
If you want to count down, you need to use .rev() instead
```rust,editable
for i in (1..10).rev(){
println!("fizzbuzz");
}
```
## for and iterators

The `for in` construct is able to interact with an `Iterator` in several ways.
Expand Down
Loading