From: Zhao Yi Date: 2008-11-17T16:50:46+09:00 Subject: Re: How can I overload a method in Ruby Einar Magnç‚­s Boson wrote: > there is no overloading, only overriding. > > > You can have variable number of arguments by writing > > def fun(*params) > #here params is an array of your arguments, [] if none. > end > > you can also have a default value for your parameter: > > class Impl > include MyModule > > def fun(directory = "") > puts "fun #{directory}" > end > > end > m=Impl.new() > m.fun() > # >> fun > m.fun "/dev/null" > # >> fun /dev/null" ok I understand. Just curious, overload is a good feature in OO programming. Why doesn't Ruby support it? If I use the method you mentioned, I have to check the parameters and use if - else or swith to distinguish them. -- Posted via http://www.ruby-forum.com/.