From: Jonan Scheffler Date: 2012-12-28T03:50:09+09:00 Subject: Re: numeric? --e89a8f64675914f5e504d1da04dd Content-Type: text/plain; charset=ISO-8859-1 You might be better off to ask yourself why you need the type checking anyway. If you have a method designed to handle an argument that might be a string or an integer you might be trying to do two different things. If you're sure you want the integer you could just to_i the input. On Dec 27, 2012 10:40 AM, "Brandon Weaver" wrote: > I've found a bit of an annoyance trying to find out if a number is numeric > or not. I thought it would probably be a simple string method but I found > far more contrived solutions like regex matches. Eventually I settled on > monkey patching string with a Numeric? method using Float(self)! = nil > rescue false. > > Is there a better way to go about this? If not, can we get something added > to the core? > > Thanks for your time, > > Brandon > --e89a8f64675914f5e504d1da04dd Content-Type: text/html; charset=ISO-8859-1 Content-Transfer-Encoding: quoted-printable

You might be better off to ask yourself why you need the typ= e checking anyway. If you have a method designed to handle an argument that= might be a string or an integer you might be trying to do two different th= ings.

If you're sure you want the integer you could just to_i = the input.

On Dec 27, 2012 10:40 AM, "Brandon Weaver&q= uot; <keystonelemur@gmail.com= > wrote:

I've found a bit of an annoyance trying to find out if a number is n= umeric or not. I thought it would probably be a simple string method but I = found far more contrived solutions like regex matches. Eventually I settled= on monkey patching string with a Numeric? method using Float(self)! =3D ni= l rescue false.

Is there a better way to go about this? If not, can we get something add= ed to the core?

Thanks for your time,

Brandon

--e89a8f64675914f5e504d1da04dd--