[lnkForumImage]
TotalShareware - Download Free Software

Confronta i prezzi di migliaia di prodotti.
Asp Forum
 Home | Login | Register | Search 


 

Forums >

comp.lang.ruby

Array question

Peter Szinek

11/9/2006 1:01:00 PM

Hello,


I have a function like this:

def f(*args)
#do something
end

and I have an array, say

a = [1,2,3]

Now I would like to call f() with the contents of the array i.e.

f(1,2,3) in this case (i.e. not f([1,2,3]) )

What is the most Rubyish way to accomplish this?

TIA,
Peter

--
http://www.rubyra...

1 Answer

Farrel Lifson

11/9/2006 1:05:00 PM

0

On 09/11/06, Peter Szinek <peter@rubyrailways.com> wrote:
> Hello,
>
>
> I have a function like this:
>
> def f(*args)
> #do something
> end
>
> and I have an array, say
>
> a = [1,2,3]
>
> Now I would like to call f() with the contents of the array i.e.
>
> f(1,2,3) in this case (i.e. not f([1,2,3]) )
>
> What is the most Rubyish way to accomplish this?
>
> TIA,
> Peter
>
> --
> http://www.rubyra...
>
>

f(*a)

Farrel