From: Steve Tuckner Date: 2001-08-09T22:17:12+09:00 Subject: [ruby-talk:19427] Simple Question This message is in MIME format. Since your mail reader does not understand this format, some or all of this message may not be legible. ------_=_NextPart_001_01C120D4.7A5D3950 Content-Type: text/plain; charset="iso-8859-1" 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 ------_=_NextPart_001_01C120D4.7A5D3950 Content-Type: text/html; charset="iso-8859-1"
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
------_=_NextPart_001_01C120D4.7A5D3950--