From: "ara.t.howard" Date: 2007-08-10T05:08:18+09:00 Subject: Re: define_method with default parameters On Aug 9, 2007, at 11:20 AM, Gordon Thiesfeld wrote: > > Not sure if this is the most elegant way, but: > > define_method(:method_name) do |*args| > parameter, parameter2 = *args > parameter2 ||= 'default' > puts parameter > puts parameter2 > end > > > i prefer define_method 'method_name' do |required, *optional| one, two, *ignored = *optional end because you an error will be thrown if required is not passed and you don't risk slurping ten arguments into 'two' alternatively just use a hash define_method 'method_name' do |required, *options| options = options.first || Hash.new foobar = options[:foobar] end method_name 'required' method_name 'required', :foobar => 42 kind regards. a @ http://drawohara.com/ -- we can deny everything, except that we have the possibility of being better. simply reflect on that. h.h. the 14th dalai lama