On Nov 10, 4:38 am, Trans <transf... / gmail.com> wrote:
> OK. If this works in 1.9, then I think it's good enough.
>
>   def foo(*args, keys)
>     args  #=> [1,2,3]
>     keys  #=> {:a=>1, :b=>2}
>   end
>
>   foo(1,2,3, a:=>1, :b=2}

I just realized that this isn't good enough b/c it wouldn't properly
handle the case when no options were passed. The interface would need
to be:

   def foo(*args, keys={})
     args  #=> [1,2,3]
     keys  #=> {:a=>1, :b=>2}
   end

But it still doesn't work b/c keys will catch the last parameter no
matter waht it is --options hash or not.

So I'm pleading with Matz and the Ruby community. Lets get keyword
arguments into the language. I think:

  def foo(*args, **keys)
  end

Where keys then captures any trailing hash pairs is the best solution.
After all, it's what we already do today but without having to parse
*args by hand.

I know some of you are in favor of Python's way, but I'm asking you to
put that aside since it really changes the whole arguments matrix --
let's stick with what we know. And by doing so, it's not a difficult
patch, we can get it into 1.9, rather than wait for 2.0.

Thanks,
T.