Created
October 7, 2012 18:59
-
-
Save ben0x539/3849236 to your computer and use it in GitHub Desktop.
This file contains 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 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