From: pete@... (Pete Goodeve) Date: 2006-03-15T18:08:46+09:00 Subject: Re: Hash default -- what's going on here? In article , Daniel Baird wrote: >------=_Part_6549_12041498.1142407055374 >Content-Type: text/plain; charset=ISO-8859-1 >Content-Transfer-Encoding: quoted-printable >Content-Disposition: inline > >I'm guessing it's got something to do with your assignment > > table[a]=3Dt > >the array that is the hash's default can be assigned to. I think that's >what you're doing. If i did some testing I might be more sure :) > Heh -- you can tell I'm new to ruby... (:-)) An hour after I posted I suddenly realized what is going on. When you assign an array, the array is *not* copied! the assigned-to variable just gets a pointer to the other array. So when I did "t=table[a]" I was setting t to a pointer to the default! When I changed t[n], of course the default was actually what got changed... Sigh. Hardly a novel gotcha, but I fell right into it. Not sure of the best way to do what I want -- maybe just use 'has_key?' and then do the right thing. -- Pete --