On Jan 23, 2006, at 6:01 PM, Mauricio Fernandez wrote:

> On Tue, Jan 24, 2006 at 03:02:04AM +0900, James Edward Gray II wrote:
>> The following code, adapted from an old post by Guy Decoux seems to
>> do the trick:
>>
>> class WeakCache
>>    def initialize( cache = Hash.new )
>>       @cache = cache
>>    end
> [...]
>>    def []=( key, value )
>>       ObjectSpace.define_finalizer(value, lambda { @cache.delete 
>> (key) })
>                                              
> ==============================
> This keeps a reference to value so it will never be reclaimed:

[snip sensational examples]

Thank you for the excellent lesson!

James Edward Gray II