From: Brandon Weaver Date: 2012-12-28T03:58:20+09:00 Subject: Re: numeric? --047d7b1604b95222d004d1da21df Content-Type: text/plain; charset=ISO-8859-1 I can't control null returns on certain statements considering it retrieves data from live devices. If a live device is down it returns null or similar. There are enough different devices that report different variants of null that in order to be more flexible, numeric is my most viable option. On Dec 27, 2012 12:54 PM, "Tony Arcieri" wrote: > 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 > --047d7b1604b95222d004d1da21df Content-Type: text/html; charset=ISO-8859-1 Content-Transfer-Encoding: quoted-printable

I can't control null returns on certain statements considering it re= trieves data from live devices. If a live device is down it returns null or= similar. There are enough different devices that report different variants= of null that in order to be more flexible, numeric is my most viable optio= n.

On Dec 27, 2012 12:54 PM, "Tony Arcieri&quo= t; <tony.arcieri@gmail.com= > wrote:
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=
--047d7b1604b95222d004d1da21df--