Hello -- On Mon, 13 May 2002, Dossy wrote: > On 2002.05.12, David Alan Black <dblack / candle.superlink.net> wrote: > > It's like saying: 'val1'.to_a == ['val1', 'val2'] > > which I don't think makes sense. (I know you're talking about a > > particular case, not generally saying that strings should do that, > > but this is what I think it boils down to.) > > I'm saying that 'val1' == 'val1' and that 'val1'.to_a == ['val1'] > and ['val1', 'val2'].to_a == ['val1', 'val2']. The only "strange" > behavior I'm suggesting is: > > ['val1', 'val2'].to_s == 'val1' > > Well, not #to_s, but #[] of the cgi class, in this case. OK... you said, given a case where there are two values: > p['name'] always returns val1. p['name'].to_a returns the array of > values. So, if p['name'] returns 'val1', then the object on which you're calling #to_a to is 'val1'. The #[] method doesn't know that #to_a is going to be called on its return value. It's like: res = p['name'] # => 'val1' res.to_a # => ['val1','val2'] Hence my thought that: > > It's like saying: 'val1'.to_a == ['val1', 'val2'] Now, it may not exactly be a String that p['name'] returns -- in fact, I think it would have to be an object that somehow stored the other array elements, so that if #to_a is called on it, it can restore them. At that point, in addition to at least the "feel" of #to_a behaving too magically, I start to wonder why not just make the array elements clearly visible in the first place. David -- David Alan Black home: dblack / candle.superlink.net work: blackdav / shu.edu Web: http://pirate.shu.edu/~blackdav