--Apple-Mail-14--698435744 Content-Transfer-Encoding: 7bit Content-Type: text/plain; charset=US-ASCII; format=flowed Please don't top post. With all the stuff in this thread, I find it nearly impossible to figure out what you have and haven't tried. On 13 Mar 2005, at 12:46, Sam Roberts wrote: > (I sent this to ruby-doc by accident, and got a response, but I am > reposting to ruby-talk, sorry for the cross-post.) > > Thanks, thats very informative, and I would not have guessed. > > I tried a different approach, I derived from String. This has the > very odd behaviour of blowing the Stack! > > class Str < String > def hash; self.downcase.hash; end # <- this doesn't look recursive > # to me, but it blows the stack > end > > h } > > k tr.new('a') > > k 'A' > 'A' k > > h[k] lower' > > k tr.new('A') > p k.downcase # Should return an instance of String, right? > p k.downcase.hash # <--- this line cause stack overflow > k.hash 'a'.hash > > h.has_key? k > > What am I missing? To store into the same slot of a Hash, an object must have the same #hash as the object it would replace and be #eql?. -- Eric Hodel - drbrain / segment7.net - http://segment7.net FEC2 57F1 D465 EB15 5D6E 7C11 332A 551C 796C 9F04 --Apple-Mail-14--698435744 content-type: application/pgp-signature; x-mac-type=70674453; name P.sig content-description: This is a digitally signed message part content-disposition: inline; filename=PGP.sig content-transfer-encoding: 7bit -----BEGIN PGP SIGNATURE----- Version: GnuPG v1.2.4 (Darwin) iD8DBQFCNL3uMypVHHlsnwQRAg/OAJ42Oi8/kb17v6s7y71ms6OyUXqXywCgywar lSr/HzYztWWU/ke3xzYonOo DA -----END PGP SIGNATURE----- --Apple-Mail-14--698435744--