From: Justin Collins Date: 2006-08-02T08:50:57+09:00 Subject: Re: Sending Multiple Args to a Method Object Justin Collins wrote: > Phillip Hutchings wrote: >> On 8/2/06, Harris Reynolds wrote: >>> The ruby interpreter thinks that my single array is the parameter I >>> am passing in; however, the array I am passing in contains 4 object >>> that map directly to the 4 arguments the interpreter is looking >>> for. Is there another way to accomplish this other than using >>> method.call? Or am I using method.call incorrectly? >> >> Put a * before the array argument, it'll make Ruby expand it to fit >> the arguments, eg: >> >> def test(one, two, three, four) >> puts "#{one} #{two} #{three} #{four}" >> end >> >> args = [1, 2, 3, 4] >> m = method(:test) >> m.call(*args) > > Note that you do not need to use Method#call to do this, it works for > all methods (since the OP was asking if he had to use it). > Or maybe he wasn't. Either way. -Justin