On 8/2/06, Harris Reynolds <hreynolds2 / yahoo.com> 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)
--
Phillip Hutchings
http://www.sitharus.com/