From: Daniel Carrera Date: 2003-06-27T14:34:26+09:00 Subject: Re: method overloading? -----BEGIN PGP SIGNED MESSAGE----- Hash: SHA1 Ruby Application Archive. http://raa.ruby-lang.org It's analogous to CPAN, CTAN and the Vaults. On Fri, Jun 27, 2003 at 02:31:09PM +0900, Donglai Gong wrote: > What is RAA? Is there any documentation for it? Thanks. > > Donglai > > On Friday, Jun 27, 2003, at 01:21 US/Eastern, Ryan Pavlik wrote: > > >On Fri, 27 Jun 2003 13:43:42 +0900 > >Donglai Gong wrote: > > > >>Is there a way to implement method overloading in ruby? Naively I > >>just > >>defined two methods with the same name with different number of > >>parameters...Ruby didn't like that. > >> > >>Donglai > > > > > > > >The StrongTyping module on RAA lets you do this: > > > > def foo(*args) > > overload(args, String) { > > ... > > return ... > > } > > > > overload(args, String, String) { > > ... > > return ... > > } > > > > ... > > > > overload_default args > > end > > > >Of course, if you don't care what type of object you want > >specifically, you can just say "Object", and you can specify multiple > >types like [String, NilClass]. > > > > > > > > > >-- > >Ryan Pavlik > > > >"Ye don't like me? But we don't even know each other. I > > bets we have a lot in common. Treachery and such. Yar." - 8BT > > > - -- Daniel Carrera | OpenPGP fingerprint: Graduate TA, Math Dept | 6643 8C8B 3522 66CB D16C D779 2FDD 7DAC 9AF7 7A88 UMD (301) 405-5137 | http://www.math.umd.edu/~dcarrera/pgp.html -----BEGIN PGP SIGNATURE----- Version: GnuPG v1.2.2 (SunOS) iD8DBQE++9dcnxE8DWHf+OcRAvQDAKCHurhslqK8ufDgOGEhpWNqqW4NlACcCXFq riuo3zsuczQp2ldBuDzbvu0= =btKo -----END PGP SIGNATURE-----