From: "Erik Bågfors" Date: 2001-11-28T23:03:51+09:00 Subject: [ruby-talk:26788] Re: overload possible? Well.. you kind of can.... def test1(a,b=3) puts "a = #{a}" puts "b = #{b}" end def test2(*args) puts "number of args = " + args.length.to_s puts "arguments are:" args.each { |a| print a } puts end test1(1,2) test1(1) test2(1,2,3) test2(1,2,3,4,5) It's not the same as method overloading but you can get the same concept easy. For example def method_that_takes_two_args(a,b) blaha end def method_that_takes_three_args(a,b,c) blaha end def method_x(*args) if (args.lenght == 2) method_tat_takes_two_args(args[0],args[1]) elsif(args.length == 3) method_that_takes_three_args(args[0],args[1],args[3]) else raise blaha end end /Erik On Wed, 2001-11-28 at 14:45, Wyss Clemens wrote: > No, UNLESS you ask Guy Decoux (ts) to give you his *extension* > ;-) > Clemens > > > -----Original Message----- > > From: Masanori Fujita [mailto:fujita@uni-muenster.de] > > Sent: Mittwoch, 28. November 2001 12:51 > > To: ruby-talk@ruby-lang.org > > Subject: [ruby-talk:26770] overload possible? > > > > > > Hello, > > > > is it possible to define Ruby methods with the same names but > > different > > number of arguments (overload concept in other languages) ? > > > > Masanori > > > > -- Erik B�gfors | erik@bagfors.nu Supporter of free software | GSM +46 733 279 273 fingerprint: 6666 A85B 95D3 D26B 296B 6C60 4F32 2C0B 693D 6E32