From: "David A. Black" Date: 2008-04-11T07:21:34+09:00 Subject: Re: How can I demonstrate that weakref works in 1.9? Hi -- On Fri, 11 Apr 2008, Dave Thomas wrote: > > For 1.8, I did > > require 'weakref' > ref = "fol de rol" > puts "Initial object is #{ref}" > ref = WeakRef.new(ref) > puts "Weak reference is #{ref}" > ObjectSpace.garbage_collect > puts "But then it is #{ref}" > > The last line raised an Illegal Reference exception, which I expected. > > In 1.9, however, no exception is thrown--the original object is returned. > > So, assuming Weakref works in 1.9, is there a clever way of demonstrating it? I wanted to try this out and investigate but I can't seem to get the exception out of 1.8: $ ruby -v weakref.rb ruby 1.8.6 (2007-09-24 patchlevel 111) [universal-darwin9.0] Initial object is fol de rol Weak reference is fol de rol But then it is fol de rol David -- Rails training from David A. Black and Ruby Power and Light: ADVANCING WITH RAILS April 14-17 New York City INTRO TO RAILS June 9-12 Berlin ADVANCING WITH RAILS June 16-19 Berlin See http://www.rubypal.com for details and updates!