Created
June 6, 2014 14:28
-
-
Save JimPanic/42165de94c660429d24c to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
use std::iter::Range; | |
fn main() { | |
println!("I am such a great program. I can count to ten.") | |
let start = 1; | |
let stop = 10; | |
start = 2; | |
for i in natural_range(start, stop) { | |
match i { | |
10 => println!("and {}.", i), | |
_ => print!("{}...", i) | |
} | |
} | |
} | |
fn natural_range (start: uint, stop: uint) -> Range<uint> { | |
range(start, stop + 1) | |
} | |
/* | |
<anon>:8:5: 8:10 error: re-assignment of immutable variable `start` | |
<anon>:8 start = 2; | |
^~~~~ | |
<anon>:5:9: 5:14 note: prior assignment occurs here | |
<anon>:5 let start = 1; | |
^~~~~ | |
error: aborting due to previous error | |
playpen: application terminated with error code 101 | |
*/ |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment