From: Brian Adkins Date: 2008-11-18T02:51:40+09:00 Subject: Re: How can I overload a method in Ruby pjb@informatimago.com (Pascal J. Bourguignon) writes: > Zhao Yi writes: >> I want to write a build method which will build source code in a >> directory. I assume there are two build methods, one doesn't have >> parameter while the other have one parameter. The method without >> parameter will build the source code in default directory, the method >> with one parameter will build the source code in the directory which is >> specified by this parameter. With method overloading, I can write them >> as below: >> >> def build() >> make >> end >> >> def build(directory) >> cd directory >> make >> end > > Call it: buildWithDirectory(directory) build_with_directory would probably be a more conventional Ruby function name. -- Brian Adkins http://www.lojic.com/ http://lojic.com/blog/