From: David Vallner Date: 2006-11-20T02:40:23+09:00 Subject: Re: ruby equivalent PHP function is_numeric? --------------enigE291B1F6ACAB3C0E7941C2E1 Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: quoted-printable Timothy Hunter wrote: > matt neuburg wrote: >> Michael Fellinger wrote: >> >> =20 >>> class String >>> def to_numeric >>> Integer(self) rescue Float(self) rescue nil >>> end >>> end >>> =20 >> >> Where can I find documentation on the syntax of "rescue" that makes th= is >> work? >> >> Thx - m. >> >> =20 > Pickaxe 2nd ed. page 374: "Exceptions may be handled...after the > execution of a single statement." >=20 It's basically a hack around the fact that as "if", "while", etc. are available as both block forms and statement modifiers, "rescue" is only a statement modifier. There is no "syntax of rescue" that makes this work, as this is in fact the only syntax of rescue ;) David Vallner --------------enigE291B1F6ACAB3C0E7941C2E1 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) iD8DBQFFYJb8y6MhrS8astoRAk/CAJ9jIJKzw6OCp3mWKFwnyy8a4nWFhACePBVQ VS5x5t6qFs+9o0dodfOIxEc= =yI35 -----END PGP SIGNATURE----- --------------enigE291B1F6ACAB3C0E7941C2E1--