From: David Vallner Date: 2006-10-20T05:06:41+09:00 Subject: Re: detecting data type --------------enigC13127638AEFE392115ECF62 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: quoted-printable Parv G. wrote: > hello all, > i'm new to ruby and need some help on what seems like a simple issue. >=20 > How do i find out if the argument passed to a method is a string or an = > integer? >=20 > Here's what i'm trying to do: >=20 > def method_test(some_arg) > if some_arg is string > #callmethod A > else > #callmethod B > end > end >=20 Not repeating the obvious duck-type-but-not-really-cause-that-says-nothing-anyway, applying the "replace conditional with polymorphism" refactoring is probably the cleanest solution from an OO point of view. More so because this is trivial with Ruby's open classes, and the standard library probably has what you need (like a type conversion method). David Vallner --------------enigC13127638AEFE392115ECF62 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) iD8DBQFFN9rEy6MhrS8astoRAgxCAJ40MhnkHIOOXtFeJUaFQKv0TEPMhwCdHDko SxcHN7v68Ii3KeDig3BLbwI= =jPaA -----END PGP SIGNATURE----- --------------enigC13127638AEFE392115ECF62--