From: Chris White Date: 2011-08-11T00:16:10+09:00 Subject: Re: Passing multiple parameters On Aug 10, 2011, at 8:10 AM, Avantec Van wrote: > Hi, > > I have a method & i wanna pass around 25 parameters to it and i hav to > make string from that, as follows... I wouldn't recommend writing a method that takes 25 parameters, but moving along... > > def method1(email, b_day, b_month, b_year, gender, f_name, l_name, > mdl_name, title, country, .......) > > params = > "email=#{email}&birth_day=#{b_day}&birth_year=#{b_year}.............." > > end > > it looks very odd when passing these many parameters. Is there any other > option that I can mention only mandatory args in the method & remaining > all are in single argument or something like that? Yes, you can do this: def method1(required, required, required, *args) Which Ruby will fill *args with remaining arguments as an array (empty array if there are none): >> def test(a,b,*args) >> p a,b,args >> end => nil >> test(1,2,3,4,5) 1 2 [3, 4, 5] Another option is to pass either an object in, or a Hash. I'd recommend this path if the data you're dealing with relates to each other (which it looks like it does). Regards, Chris White http://www.twitter.com/cwgem