|Posted by Jesse Phillips||PermalinkReply|
> Ruby code (can't break it, if you enter floats it just rounds down, if you enter non-numbers it just assumes zero, so no errors):
Since you got your answer I would just like to point out that this is not the philosophy driving D. If you are storing to an int what you give it should convert to an int, otherwise you should explicitly say it may not be an integer (which is done with try/catch in D)
I have a library I made that handles user input, and if it isn't what you want, then it asks the user until the user actually provides the correct value. The interface is described in the link below, I have not yet made the code available.
Also examples are usually pretty old.