View mode: basic / threaded / horizontal-split · Log in · Help
September 10, 2010
Re: Input handling? (newbie alert!)
Cavalary Wrote:

> 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[1] 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.

1. http://www.digitalmars.com/pnews/read.php?server=news.digitalmars.com&group=digitalmars.D&artnum=115546
Top | Discussion index | About this forum | D home