From: "David A. Black" Date: 2003-12-06T01:10:42+09:00 Subject: Re: Dumb question to which I ought to know the answer by now Hi -- On Sat, 6 Dec 2003, Michael Campbell wrote: > Mark J. Reed wrote: > > > On Fri, Dec 05, 2003 at 11:32:51PM +0900, nobu.nokada@softhome.net > wrote: > > > >>Once I'd proposed similar; > >> > >> hash[*keys] = *values > >> > > > > > > That would be handy, but I don't think it's possible to define such > > a method in current Ruby. The parameters to []= are flattened; > > you wouldn't be able to tell where the keys stopped and the values > > started, unless you assumed that keys.length == values.length, > which > > is not always a valid assumption where I've seen the Perl idiom > used. > > > I think in Nobu's code, keys and values are separate arrays, so there > is no need to know where keys stop and values begin. Or have I > misread? I think what Mark means is that if you've got this: def []=(keys,values) and you do what amounts to this: hash[1,2,3] = 4,5,6 then in effect you've got a call like this: hash[]=(1,2,3,4,5,6) which doesn't fit the two-arg format, and has no unambiguous dividing line (unless you decide that the key and value lists have to be of the same length, which I actually think would be reasonable, though as Mark says not identical to the Perl idiom [which I don't mind :-) ]). David -- David A. Black dblack@wobblini.net