From: "Zachary P. Landau" Date: 2003-11-19T01:59:52+09:00 Subject: Re: testing argument type and duck typing, newbie question --yEPQxsgoJgBvi8ip Content-Type: text/plain; charset=us-ascii Content-Disposition: inline Content-Transfer-Encoding: quoted-printable > >I have a method taking one argument that can be an integer or a string. > >How do I test the argument to know if it's a string or an integer? All= =20 > >the duck typing things I've read make me wonder what's the best way=20 > >to determine if the argument is an integer or a string..... [...] > or if you wont you can get StrongTyping and do: >=20 > def f(a,b) > expect(String,a,Integer,b) > end He wanted a single argument with multiple possibilities. With StrongTyping, that would be: def f(a) expect(a, [String, Integer]) end --=20 Zachary P. Landau GPG: gpg --recv-key 0x24E5AD99 | http://kapheine.hypa.net/kapheine.asc --yEPQxsgoJgBvi8ip Content-Type: application/pgp-signature Content-Disposition: inline -----BEGIN PGP SIGNATURE----- Version: GnuPG v1.2.3 (GNU/Linux) iD8DBQE/uk/LCwWyMCTlrZkRAiA2AJwNDHaiKTaZljDVkBfUNiQdCj4f7QCdHHaU lsYQy/1dIuTgmPs6yJvKV8g= =iSje -----END PGP SIGNATURE----- --yEPQxsgoJgBvi8ip--