On Mon, 12 Sep 2005, Daniel Schierbeck wrote:

> I'm writing a class representing a coordinate system, and I want to be able 
> to give a point in the system a value (eg. a label). The problem is that the 
> system can have a variable number of 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?

   def []=(*a)
     value = a.pop
     coordinates = a
     raise ArgumentError if value.nil? or coordinate.empty?
     ...
   end

hth.

-a
-- 
===============================================================================
| email :: ara [dot] t [dot] howard [at] noaa [dot] gov
| phone :: 303.497.6469
| Your life dwells amoung the causes of death
| Like a lamp standing in a strong breeze.  --Nagarjuna
===============================================================================