Array question

P

Peter Szinek

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
 
F

Farrel Lifson

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

f(*a)

Farrel
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,776
Messages
2,569,603
Members
45,188
Latest member
Crypto TaxSoftware

Latest Threads

Top