A RetroSearch Logo

Home - News ( United States | United Kingdom | Italy | Germany ) - Football scores

Search Query:

Showing content from https://docs.ruby-lang.org/en/master/WeakRef.html below:

class WeakRef - Documentation for Ruby 3.5

class WeakRef

Weak Reference class that allows a referenced object to be garbage-collected.

A WeakRef may be used exactly like the object it references.

Usage:

foo = Object.new            
p foo.to_s                  
foo = WeakRef.new(foo)      
p foo.to_s                  
GC.start                    
p foo.to_s                  
Constants
VERSION
Public Class Methods

Source

def initialize(orig)
  case orig
  when true, false, nil
    @delegate_sd_obj = orig
  else
    @@__map[self] = orig
  end
  super
end

Creates a weak reference to orig

Public Instance Methods

Source

def weakref_alive?
  @@__map.key?(self) or defined?(@delegate_sd_obj)
end

Returns true if the referenced object is still alive.


RetroSearch is an open source project built by @garambo | Open a GitHub Issue

Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo

HTML: 3.2 | Encoding: UTF-8 | Version: 0.7.3