# Variable-Length arg list and blocks

**URL:** <https://www.ruby-forum.com/t/variable-length-arg-list-and-blocks/110985>\
**Category:** Ruby\
**Created:** [August 1, 2007, 6:53pm UTC](https://www.ruby-forum.com/t/variable-length-arg-list-and-blocks/110985 "2007-08-01T18:53:48Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![dizzyone](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/d/b2d939/32.png) [@dizzyone](https://www.ruby-forum.com/u/dizzyone)\
**Post date:** [August 1, 2007, 6:53pm UTC](https://www.ruby-forum.com/t/variable-length-arg-list-and-blocks/110985/1 "2007-08-01T18:53:48Z")

</div>

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.

---

<div class="post-metadata">

**Author:** ![dizzyone](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/d/b2d939/32.png) [@dizzyone](https://www.ruby-forum.com/u/dizzyone)\
**Post date:** [August 1, 2007, 7:01pm UTC](https://www.ruby-forum.com/t/variable-length-arg-list-and-blocks/110985/2 "2007-08-01T19:01:57Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![dizzyone](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/d/b2d939/32.png) [@dizzyone](https://www.ruby-forum.com/u/dizzyone)\
**Post date:** [August 1, 2007, 7:05pm UTC](https://www.ruby-forum.com/t/variable-length-arg-list-and-blocks/110985/3 "2007-08-01T19:05:07Z")

</div>

Stefano C. 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
