Linux server1.dn-server.com 4.18.0-553.89.1.lve.el8.x86_64 #1 SMP Wed Dec 10 13:58:50 UTC 2025 x86_64
LiteSpeed
Server IP : 195.201.204.189 & Your IP : 216.73.216.45
Domains :
Cant Read [ /etc/named.conf ]
User : beriska1
Terminal
Auto Root
Create File
Create Folder
Localroot Suggester
Backdoor Destroyer
Readme
/
opt /
alt /
ruby20 /
share /
ri /
2.0.0 /
system /
WeakRef /
Delete
Unzip
Name
Size
Permission
Date
Action
RefError
[ DIR ]
drwxr-xr-x
2026-05-01 04:24
cdesc-WeakRef.ri
2.8
KB
-rw-r--r--
2023-07-26 17:38
new-c.ri
439
B
-rw-r--r--
2023-07-26 17:38
weakref_alive%3f-i.ri
335
B
-rw-r--r--
2023-07-26 17:38
Save
Rename
U:RDoc::NormalClass[iI"WeakRef:ET@I"Delegator;To:RDoc::Markup::Document:@parts[o;;[o:RDoc::Markup::Paragraph;[I"@Weak Reference class that allows a referenced object to be ;TI"garbage-collected.;To:RDoc::Markup::BlankLine o; ;[I"AA WeakRef may be used exactly like the object it references.;T@o; ;[I"Usage:;T@o:RDoc::Markup::Verbatim;[I"@foo = Object.new # create a new object instance ;TI"4p foo.to_s # original's class ;TI"Ffoo = WeakRef.new(foo) # reassign foo with WeakRef instance ;TI"8p foo.to_s # should be same class ;TI"?GC.start # start the garbage collector ;TI"Ep foo.to_s # should raise exception (recycled) ;T:@format0S:RDoc::Markup::Heading: leveli: textI"Example;T@o; ;[I"QWith help from WeakRef, we can implement our own redimentary WeakHash class.;T@o; ;[I"PWe will call it WeakHash, since it's really just a Hash except all of it's ;TI".keys and values can be garbage collected.;T@o;;[I"require 'weakref' ;TI" ;TI"class WeakHash < Hash ;TI" def []= key, obj ;TI"2 super WeakRef.new(key), WeakRef.new(obj) ;TI" end ;TI" end ;T;0o; ;[I"SThis is just a simple implementation, we've opened the Hash class and changed ;TI"OHash#store to create a new WeakRef object with +key+ and +obj+ parameters ;TI";before passing them as our key-value pair to the hash.;T@o; ;[I"OWith this you will have to limit your self to String key's, otherwise you ;TI"Owill get an ArgumentError because WeakRef cannot create a finalizer for a ;TI"CSymbol. Symbols are immutable and cannot be garbage collected.;T@o; ;[I"Let's see it in action:;T@o;;[I"omg = "lol" ;TI"c = WeakHash.new ;TI"c['foo'] = "bar" ;TI"c['baz'] = Object.new ;TI"c['qux'] = omg ;TI"puts c.inspect ;TI"I#=> {"foo"=>"bar", "baz"=>#<Object:0x007f4ddfc6cb48>, "qux"=>"lol"} ;TI" ;TI"%# Now run the garbage collector ;TI"GC.start ;TI"c['foo'] #=> nil ;TI"c['baz'] #=> nil ;TI"c['qux'] #=> nil ;TI"omg #=> "lol" ;TI" ;TI"puts c.inspect ;TI"B#=> WeakRef::RefError: Invalid Reference - probably recycled ;T;0o; ;[ I"QYou can see the local variable +omg+ stayed, although it's reference in our ;TI"Lhash object was garbage collected, along with the rest of the keys and ;TI"Rvalues. Also, when we tried to inspect our hash, we got a WeakRef::RefError, ;TI"?this is because these objects were also garbage collected.;T: @fileI"lib/weakref.rb;T:0@omit_headings_from_table_of_contents_below0;0;0[ [ [ [[I" class;T[[:public[[I"new;TI"lib/weakref.rb;T[:protected[ [:private[ [I" instance;T[[;[[I"weakref_alive?;F@d[;[ [;[ [ [U:RDoc::Context::Section[i 0o;;[ ;0;0[@X@XcRDoc::TopLevel