[lnkForumImage]
TotalShareware - Download Free Software

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


 

Forums >

comp.lang.ruby

Variable-Length arg list and blocks

Lolz Llolz

8/1/2007 4:55:00 PM

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.
--
Posted via http://www.ruby-....

2 Answers

Stefano Crocco

8/1/2007 5:01:00 PM

0

Alle mercoledì 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

Lolz Llolz

8/1/2007 5:05:00 PM

0

Stefano Crocco wrote:
> Alle mercoledì 1 agosto 2007, Lolz Llolz ha scritto:
>> 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
Your reply was very fast :-)
Thank you!



Turing




--
Posted via http://www.ruby-....