From: Julian Leviston Date: 2013-04-07T00:43:09+09:00 Subject: Re: Why `local_variables` printing the name of local variables,while it has been garbage collected? Local variables stick around http://viewsourcecode.org/why/hacking/theFullyUpturnedBin.html Julian On 07/04/2013, at 12:45 AM, Love U Ruby wrote: > Why `local_variables` printing the name of local variables,while it has > been garbage collected? > > require 'weakref' > > a = "abc" > p local_variables > p defined? a > p a.to_s > a = WeakRef.new(a) > p GC.enable > GC.start > p local_variables > p defined? a > p a.to_s > > Output: > > [:a] > "local-variable" > "abc" > false > [:a] > "local-variable" > true.rb:253:in `
': Invalid Reference - probably recycled > (WeakRef::RefError) > > -- > Posted via http://www.ruby-forum.com/. >