We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
WeakRef
1 parent 5b50088 commit 4d9a7e8Copy full SHA for 4d9a7e8
src/weak_ref.cr
@@ -7,10 +7,14 @@
7
# require "weak_ref"
8
#
9
# ref = WeakRef.new("oof".reverse)
10
-# p ref.value # => "foo"
+# p ref # => #<WeakRef(String):0x7f83406eafa0 @target=Pointer(Void)@0x7f83406eafc0>
11
# GC.collect
12
+# p ref # => #<WeakRef(String):0x7f83406eafa0 @target=Pointer(Void).null>
13
# p ref.value # => nil
14
# ```
15
+#
16
+# Note that the collection of objects is not deterministic, and depends on many subtle aspects. For instance,
17
+# if the example above is modified to print `ref.value` in the first print, then the collector will not collect it.
18
class WeakRef(T)
19
@target : Void*
20
0 commit comments