From: James Edward Gray II Date: 2005-09-12T03:09:03+09:00 Subject: Re: Array#[]= On Sep 11, 2005, at 1:01 PM, 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? If the slurpy arrays could be used anywhere in the list, if becomes impossible to parse the arguments correctly. In this case, you'll need to separate the value yourself: def []=( *args ) value = args.pop cooridinates = args # ... end Hope that helps. James Edward Gray II