Skip to content

Commit 601ac78

Browse files
authored
[DOC] Small changes to docs for ObjectSpace#each_object (#15564)
Change example to use user-defined class instead of `Numeric`.
1 parent f712086 commit 601ac78

File tree

1 file changed

+12
-20
lines changed

1 file changed

+12
-20
lines changed

gc.c

Lines changed: 12 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -1537,34 +1537,26 @@ os_obj_of(VALUE of)
15371537
* Ruby process. If <i>module</i> is specified, calls the block
15381538
* for only those classes or modules that match (or are a subclass of)
15391539
* <i>module</i>. Returns the number of objects found. Immediate
1540-
* objects (<code>Fixnum</code>s, <code>Symbol</code>s
1541-
* <code>true</code>, <code>false</code>, and <code>nil</code>) are
1542-
* never returned. In the example below, #each_object returns both
1543-
* the numbers we defined and several constants defined in the Math
1544-
* module.
1540+
* objects (such as <code>Fixnum</code>s, static <code>Symbol</code>s
1541+
* <code>true</code>, <code>false</code> and <code>nil</code>) are
1542+
* never returned.
15451543
*
15461544
* If no block is given, an enumerator is returned instead.
15471545
*
1548-
* a = 102.7
1549-
* b = 95 # Won't be returned
1550-
* c = 12345678987654321
1551-
* count = ObjectSpace.each_object(Numeric) {|x| p x }
1546+
* Job = Class.new
1547+
* jobs = [Job.new, Job.new]
1548+
* count = ObjectSpace.each_object(Job) {|x| p x }
15521549
* puts "Total count: #{count}"
15531550
*
15541551
* <em>produces:</em>
15551552
*
1556-
* 12345678987654321
1557-
* 102.7
1558-
* 2.71828182845905
1559-
* 3.14159265358979
1560-
* 2.22044604925031e-16
1561-
* 1.7976931348623157e+308
1562-
* 2.2250738585072e-308
1563-
* Total count: 7
1553+
* #<Job:0x000000011d6cbbf0>
1554+
* #<Job:0x000000011d6cbc68>
1555+
* Total count: 2
15641556
*
1565-
* Due to a current known Ractor implementation issue, this method will not yield
1566-
* Ractor-unshareable objects in multi-Ractor mode (when
1567-
* <code>Ractor.new</code> has been called within the process at least once).
1557+
* Due to a current Ractor implementation issue, this method does not yield
1558+
* Ractor-unshareable objects when the process is in multi-Ractor mode. Multi-ractor
1559+
* mode is enabled when <code>Ractor.new</code> has been called for the first time.
15681560
* See https://bugs.ruby-lang.org/issues/19387 for more information.
15691561
*
15701562
* a = 12345678987654321 # shareable

0 commit comments

Comments
 (0)