Weak Reference class that allows a referenced object to be garbage-collected.
require "weak_ref"
ref = WeakRef.new("oof".reverse)
p ref.value # => "foo"
GC.collect
p ref.value # => nil
Class methods
Methods
#value
Returns the referenced object or Nil
if it has been garbage-collected.
View source