From: Robert Klemme Date: 2004-09-17T20:44:51+09:00 Subject: Re: Automatic class conversion / function overloading "Tore Halvorsen" schrieb im Newsbeitrag news:slrnckldim.k7o.torehalv@jaguar.stud.ntnu.no... > Hi! Rather new to ruby, and I'm not quite sure where to look for the > information I want. > > In C++ it's possible to have function overloading... ie > > void foo(int a) and void foo(rational a) > > Do I have to resort to > > def foo(a) > case a > when Fixnum ... > when Rational ... > end > end > > or is there any other way to do this? > > ...or perhaps a way to do the functional equivalent of C++s > > class rational > { > rational(int a) { ... } // conversion constructor > } > > void foo(rational a) should now work for foo(3) You can't do that directly. However have a look at http://www.rubygarden.org/ruby?MethodOverloading Regards robert