Variable-Length arg list and blocks

L

Lolz Llolz

Hello,
a short question: is it possible to use variable length argument lists
and binding associated blocks to a method parameter at the same time?
And if it is possible, how can I do it?

I trief the following with Ruby 1.8.2, but it didn't work:

def test(&arg1,*args)
end

Of course I know, that according to the definition both modifiers have
to be used with the last parameter.



Turing.
 
S

Stefano Crocco

Alle mercoled=C3=AC 1 agosto 2007, Lolz Llolz ha scritto:
Hello,
a short question: is it possible to use variable length argument lists
and binding associated blocks to a method parameter at the same time?
And if it is possible, how can I do it?

I trief the following with Ruby 1.8.2, but it didn't work:

def test(&arg1,*args)
end

Of course I know, that according to the definition both modifiers have
to be used with the last parameter.



Turing.

You need to puts the arguments in the opposite order:

def test(*args, &blk)
end

Stefano
 
L

Lolz Llolz

Stefano said:
Alle mercoledì 1 agosto 2007, Lolz Llolz ha scritto:

You need to puts the arguments in the opposite order:

def test(*args, &blk)
end

Stefano
Your reply was very fast :)
Thank you!



Turing
 

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

No members online now.

Forum statistics

Threads
473,769
Messages
2,569,580
Members
45,054
Latest member
TrimKetoBoost

Latest Threads

Top