On Mon, Dec 16, 2013 at 2:19 PM, Matthew Kerwin <lists / ruby-forum.com> wrote:
> Probably because I'd have expected g(1,2) to print
>> 1
>> [2]
>> 1
>
> and g(1,2,3,4,5) to print
>> 1
>> [2,3,4,5]
>> 1

In other words: Gandalf, what you ask for is ambiguous.  The parser
cannot decide whether g(1,2) should give 1, [], 2 or 1, 2, 1.  There
is no automated way to decide this unless some priorities are given
with regard to args with * and those with default value.  If you think
about it that can soon get messy and Matz tends to avoid pitfalls like
these.

Note that there are other similar restrictions:

irb(main):008:0> def h(a,*b,c,*d) p [a,b,c,d] end
SyntaxError: (irb):8: syntax error, unexpected tSTAR
def h(a,*b,c,*d) p [a,b,c,d] end
              ^
(irb):8: syntax error, unexpected keyword_end, expecting $end
        from /usr/bin/irb:12:in `<main>'


Kind regards

robert


-- 
remember.guy do |as, often| as.you_can - without end
http://blog.rubybestpractices.com/