Devin Mullins wrote:
> Daniel Schierbeck wrote:
>
> > dimensions. If it just had three, I could write:
> >
> >   def []= (x, y, z, value); end
> >
> > But this being an N-dimensional coordinate system, I have to come up
> > with something else. The most logical solution to me is this:
> >
> >   def[]= (*coordinates, value); end
> >
> > But this gives a syntax error. Am I way off base, or would it be
> > useful if variable length argument lists could be written this way?
>
> Yes, that would be useful. It has been discussed many-a-time, before,
> too. :) For now, you'll have to implement your own solution in-method:
> def []= *args
>   cords, value = args[0..-2],args[-1]
>   #...
> end
>
> Personally, I'd also like to see this:
>
> def []= x, y, value
>   #...
> ordef x, y, z, value
>   #...
> ordef *args   #gets here only if neither of the first two match
>   #...
> end
>
> But none of this exists. So live with it. :)
>
> (I'd say, "Go write an RCR," but I can't imagine that 3 don't exist
> already.)

I think that you have the right sentiment, but the implemenation isn't
so good. It would make methods more compicated things to deal with. To
achieve signiture bases defintoins I think its best to stick with
multiple definitions:

  def []= x, y, value
    #...
  end

  def []= x, y, z, value
    #...
  end

  def []= *args   #gets here only if neither of the first two match
    #...
  end

I have often though they would be nice too. But how would you
distingush one from the other, by arity? Eg. #method(:[]=, 3) ?

T.