Skip to content

Instantly share code, notes, and snippets.

@JimPanic
Created June 6, 2014 14:28
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save JimPanic/42165de94c660429d24c to your computer and use it in GitHub Desktop.
Save JimPanic/42165de94c660429d24c to your computer and use it in GitHub Desktop.
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