From 62e41d3f2e48422bbdf1bb2db83ae60b255b1a1a Mon Sep 17 00:00:00 2001 From: matz Date: Fri, 16 Jan 1998 12:19:09 +0000 Subject: Initial revision git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@8 b2dd03c8-39d4-4d8f-98ff-823fe69b080e --- lib/weakref.rb | 70 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 70 insertions(+) create mode 100644 lib/weakref.rb (limited to 'lib/weakref.rb') diff --git a/lib/weakref.rb b/lib/weakref.rb new file mode 100644 index 0000000000..93b2c65ecd --- /dev/null +++ b/lib/weakref.rb @@ -0,0 +1,70 @@ +# Weak Reference class that does not bother GCing. +# +# Usage: +# foo = Object.new +# foo.hash +# foo = WeakRef.new(foo) +# foo.hash +# ObjectSpace.garbage_collect +# foo.hash # => Raises WeakRef::RefError (because original GC'ed) + +require "delegate" + +class WeakRef