From: David Vallner Date: 2006-11-18T10:27:37+09:00 Subject: Re: ruby equivalent PHP function is_numeric? --------------enig27CCDCE399C256A2165E8F0F Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: quoted-printable ara.t.howard@noaa.gov wrote: > On Sat, 18 Nov 2006, Josselin wrote: >=20 >> After reading completely my Ruby book, I cannot find a function >> equivalent to the PHP is_numeric? to test a String >> >> myString.is_numeric? (check only digits and dot character) =3D>=20 >> return true or false >> >> does it exist ? or it's more complicated than that ? (need to build a >> regex... ?) >> >> thanks >> >> joss >=20 >=20 >=20 > harp:~ > cat a.rb > def is_numeric?(n) Float n rescue false end >=20 def is_numeric?(n) begin Float n; return true rescue false end Predicate methods not returning a boolean make my skin crawl even if it's all the same difference for conditionals. David Vallner --------------enig27CCDCE399C256A2165E8F0F Content-Type: application/pgp-signature; name="signature.asc" Content-Description: OpenPGP digital signature Content-Disposition: attachment; filename="signature.asc" -----BEGIN PGP SIGNATURE----- Version: GnuPG v1.4.5 (MingW32) iD8DBQFFXmF/y6MhrS8astoRAq76AJwO3sX6PW3W4A1CKVUD23fC0+LutgCfds7P /JrGEKQoWb0FKau2kPZGFis= =BWng -----END PGP SIGNATURE----- --------------enig27CCDCE399C256A2165E8F0F--