> Steve Tuckner wrote:
> 
> How does one pass an array to a function where each element in the
> array is taken as a argument to that function.  If I use the code
> below, it ofcourse complains that there are not enough arguments for
> the function b.
> 
> def b(x, y, z)
>     print "x = #{x}, y = #{y}, z = #{z}\n"
> end
> a = [1,2,3]
> b(a)
> 
> Is there a call like a.to_args to expand them out for the call?
> 
> Thanks,
> 
> Steve Tuckner

>irb
irb(main):001:0> def f(a,b,c)
irb(main):002:1> puts a,b,c
irb(main):003:1> end
nil
irb(main):004:0> f(1,2,3)
1
2
3
nil
irb(main):005:0> a=[1,2,3]
[1, 2, 3]
irb(main):006:0> f(a)
ArgumentError: wrong # of arguments(1 for 3)
        from (irb):6:in `f'
        from (irb):6
irb(main):007:0> f(*a)
1
2
3
nil