From: Alex DeCaria Date: 2010-04-14T21:13:59+09:00 Subject: Re: Method to groom a string to floating point representation > > BTW, I would rather not do any cleaning under the hood: let the user > correct its input himself. For example, give the input to Float() and > if an error is raised (which Float does as opposed to to_f which never > raise an error), rescue it by giving feedback to the user (where you > could use your method to propose an alternative if you want) but do > not continue without letting the user know he has made a mistake and > giving him the ability to change his mind. > > Cheers, I didn't realize the difference between Float() and .to_f. Thanks for the suggestion. The user is still aware if they entered an incorrect string, since they are entering it into a GUI textbox, and the string cleaning is done after each character is entered. Thus, if they try to enter a misplaced + sign or another bad character, they won't see it appear in the textbox, which should cause them to notice it. --Alex -- Posted via http://www.ruby-forum.com/.