Ronald Fischer wrote:
> Below is a code snippet which gives me some headache:
> 
> def headache
>   yield(*(foo(1)),"bar")
> end

You can't use a 'splatted' array anywhere in a method call except at the 
end:

def foo(a, b, c)
  p [a, b, c]
end

foo(1, 2, *[3])       #=> works
foo(1, *[3], "asdf")  #=> doesn't work

I'm not quite sure why this should be, since it has an unambiguous 
meaning, unlike defining a method with a splat in the middle of the 
arguments:

def bar(a, *b, c=0)
  ...
end

The splat operator is a bit mysterious to me in this regard.....

best,
Dan

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