Skip to content

Instantly share code, notes, and snippets.

@ben0x539
Created October 7, 2012 18:59
Show Gist options
  • Save ben0x539/3849236 to your computer and use it in GitHub Desktop.
Save ben0x539/3849236 to your computer and use it in GitHub Desktop.
use io::ReaderUtil;
fn main() {
io::println("What is your favorite number?");
let my_favorite_number = (fn() -> int {
for io::stdin().each_line |line| {
match int::from_str(line) {
None => { io::println("That is not a number. :(\nTry again!"); }
Some(number) => { return number; }
}
}
fail ~"I just wanted a number...";
})();
io::println(fmt!("What? %d? That's my favorite too!", my_favorite_number));
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment