On Tue, Jan 24, 2006 at 01:17:07AM +0900, James Edward Gray II wrote: > I need a Hash-like structure, using WeakRef, so that the key value > pairs can be garbage collected as needed. I only need to support [] > () and []=(), not the whole range of Hash functions. If the pair has > been collected, I just need a simple nil returned. > > I've tried implementing this a couple of different ways, but keep > running into trouble. Does anyone have any tips? I summarized the solutions seen in this thread so far, and presented a couple new ones at http://eigenclass.org/hiki.rb?weakhash+and+weakref There are other ways to implement WeakHash, I'll probably add some to the above page (later). HTH -- Mauricio Fernandez