From: Max Muermann Date: 2006-12-04T13:53:08+09:00 Subject: Re: method overloading like Java? 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