From: Ryan Davis Date: 2008-11-17T16:42:29+09:00 Subject: Re: How can I overload a method in Ruby On Nov 16, 2008, at 23:26 , Zhao Yi wrote: short answer: you can't (via normal ruby). > When I run this program, I got this error: > > class_objects/module.rb:22:in `fun': wrong number of arguments (0 > for 1) > (ArgumentError) > from class_objects/module.rb:22 > > I declared two methods with the same name but different parameters. > Why > can't ruby support overload method? because it wasn't designed to, that's why. You can use default args to do what you want above: > def fun dir = nil > puts "fun #{dir}" > end