Create a gist now

Instantly share code, notes, and snippets.

weakref behavior
This is from the end of weakref.rb:
if __FILE__ == $0
# require 'thread'
foo = Object.new
p foo.to_s # original's class
foo = WeakRef.new(foo)
p foo.to_s # should be same class
ObjectSpace.garbage_collect
ObjectSpace.garbage_collect
p foo.to_s # should raise exception (recycled)
end
And this is the output from running it (no exception raised):
"#<Object:0x000001010b3ea0>"
"#<Object:0x000001010b3ea0>"
"#<Object:0x000001010b3ea0>"
Any thoughts on why? I haven't yet delved deeply into the code.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment