From: Tony Arcieri Date: 2012-12-28T03:53:25+09:00 Subject: Re: numeric? --bcaec51d26b852f0a604d1d9fb9b Content-Type: text/plain; charset=ISO-8859-1 Float(string) is your best bet. Why is this inadequate? Are you trying to decide if a string "looks like a number" but don't want to work with it as a number after that? On Thu, Dec 27, 2012 at 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 > -- Tony Arcieri --bcaec51d26b852f0a604d1d9fb9b Content-Type: text/html; charset=ISO-8859-1 Content-Transfer-Encoding: quoted-printable
Float(string) is your best bet. Why is this inadequate? Ar= e you trying to decide if a string "looks like a number" but don&= #39;t want to work with it as a number after that?


On Thu, Dec 27, 2012 at 10:40 AM, Brando= n Weaver <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




--
Tony Arcieri=
--bcaec51d26b852f0a604d1d9fb9b--