From: Yang Bob Date: 2006-12-04T18:09:01+09:00 Subject: Re: method overloading like Java? ------=_Part_37149_27708222.1165223337141 Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit Content-Disposition: inline I prefer this method if I have many parameters, and when I have just fewer parameters I prefer Austin Ziegler's method. Thanks : ) 2006/12/4, Max Muermann : > > On 12/4/06, Yang Bob wrote: > > But how about overloading by parameter numbers. such as: > > class FooClass { > > def foo(first){ } > > def foo(first, second) { } > > } > > > > does ruby support this ? if can not, how can we workaround this? > > > > thanks > > > > There's also this one: > > def foo opts={} > if opts[:some_parameter] > do_something_with_parameter > end > > if opts[:some_other_parameter] > do_something_with_other_parameter > end > end > > foo :some_parameter=>123, :some_other_parameter=>'abc' > > This is used as a substitute for 'true' named parameters. It is mostly > useful if you need to take a moderate number of entirely optional > parameters. > > Cheers, > Max > > ------=_Part_37149_27708222.1165223337141--