From: Chad Perrin Date: 2011-05-07T00:19:36+09:00 Subject: Re: Lets play a guessing game. (how to code this better?) --zhXaljGHf11kAtnf Content-Type: text/plain; charset=iso-8859-1 Content-Disposition: inline Content-Transfer-Encoding: quoted-printable On Fri, May 06, 2011 at 04:27:53PM +0900, Jes=FAs Gabriel y Gal=E1n wrote: >=20 > If you need to check if the full string is a valid number, you can use > Kernel#Integer, which will raise an exception: Wow. Somehow I never found that. All this time, I've been doing this: if foo.to_i.to_s =3D=3D foo =2E . . or, if appropriate: if foo.to_i.to_s =3D=3D foo.chomp Thanks for mentioning the Integer() approach. --=20 Chad Perrin [ original content licensed OWL: http://owl.apotheon.org ] --zhXaljGHf11kAtnf Content-Type: application/pgp-signature Content-Disposition: inline -----BEGIN PGP SIGNATURE----- Version: GnuPG v2.0.14 (FreeBSD) iEYEARECAAYFAk3EDmAACgkQ9mn/Pj01uKVXFwCgkYbvq7VcBr7bwx2cCNlMysp+ XXgAn0oANg2xnSIUdNYWsAGWZD4WUqkf =thsx -----END PGP SIGNATURE----- --zhXaljGHf11kAtnf--