rbs 4.0.0.dev.5 → 4.0.1.dev.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (194) hide show
  1. checksums.yaml +4 -4
  2. data/.clang-format +1 -0
  3. data/.github/workflows/c-check.yml +8 -4
  4. data/.github/workflows/comments.yml +3 -1
  5. data/.github/workflows/dependabot.yml +1 -1
  6. data/.github/workflows/ruby.yml +10 -0
  7. data/.github/workflows/rust.yml +95 -0
  8. data/CHANGELOG.md +323 -0
  9. data/Rakefile +12 -29
  10. data/Steepfile +1 -0
  11. data/config.yml +393 -37
  12. data/core/array.rbs +218 -188
  13. data/core/basic_object.rbs +9 -8
  14. data/core/class.rbs +6 -5
  15. data/core/comparable.rbs +45 -31
  16. data/core/complex.rbs +52 -40
  17. data/core/dir.rbs +57 -45
  18. data/core/encoding.rbs +5 -5
  19. data/core/enumerable.rbs +96 -91
  20. data/core/enumerator.rbs +4 -3
  21. data/core/errno.rbs +3 -2
  22. data/core/errors.rbs +31 -29
  23. data/core/exception.rbs +12 -12
  24. data/core/fiber.rbs +36 -36
  25. data/core/file.rbs +186 -113
  26. data/core/file_test.rbs +2 -2
  27. data/core/float.rbs +41 -32
  28. data/core/gc.rbs +78 -70
  29. data/core/hash.rbs +70 -60
  30. data/core/integer.rbs +32 -28
  31. data/core/io/buffer.rbs +36 -36
  32. data/core/io/wait.rbs +7 -7
  33. data/core/io.rbs +120 -135
  34. data/core/kernel.rbs +189 -139
  35. data/core/marshal.rbs +3 -3
  36. data/core/match_data.rbs +14 -12
  37. data/core/math.rbs +69 -67
  38. data/core/method.rbs +6 -6
  39. data/core/module.rbs +146 -85
  40. data/core/nil_class.rbs +4 -3
  41. data/core/numeric.rbs +35 -32
  42. data/core/object.rbs +6 -8
  43. data/core/object_space.rbs +11 -10
  44. data/core/pathname.rbs +131 -81
  45. data/core/proc.rbs +65 -33
  46. data/core/process.rbs +219 -201
  47. data/core/ractor.rbs +15 -11
  48. data/core/random.rbs +4 -3
  49. data/core/range.rbs +52 -47
  50. data/core/rational.rbs +5 -5
  51. data/core/rbs/unnamed/argf.rbs +58 -51
  52. data/core/rbs/unnamed/env_class.rbs +18 -13
  53. data/core/rbs/unnamed/main_class.rbs +123 -0
  54. data/core/rbs/unnamed/random.rbs +7 -5
  55. data/core/regexp.rbs +236 -197
  56. data/core/ruby.rbs +1 -1
  57. data/core/ruby_vm.rbs +32 -30
  58. data/core/rubygems/config_file.rbs +5 -5
  59. data/core/rubygems/errors.rbs +1 -1
  60. data/core/rubygems/requirement.rbs +5 -5
  61. data/core/rubygems/rubygems.rbs +5 -3
  62. data/core/set.rbs +17 -16
  63. data/core/signal.rbs +2 -2
  64. data/core/string.rbs +311 -292
  65. data/core/struct.rbs +26 -25
  66. data/core/symbol.rbs +25 -24
  67. data/core/thread.rbs +40 -34
  68. data/core/time.rbs +47 -42
  69. data/core/trace_point.rbs +34 -31
  70. data/core/true_class.rbs +2 -2
  71. data/core/unbound_method.rbs +10 -10
  72. data/core/warning.rbs +7 -7
  73. data/docs/collection.md +1 -1
  74. data/docs/config.md +171 -0
  75. data/docs/inline.md +110 -4
  76. data/docs/syntax.md +13 -12
  77. data/ext/rbs_extension/ast_translation.c +489 -135
  78. data/ext/rbs_extension/class_constants.c +8 -0
  79. data/ext/rbs_extension/class_constants.h +4 -0
  80. data/ext/rbs_extension/legacy_location.c +28 -51
  81. data/ext/rbs_extension/legacy_location.h +37 -0
  82. data/ext/rbs_extension/main.c +12 -20
  83. data/include/rbs/ast.h +423 -195
  84. data/include/rbs/lexer.h +2 -2
  85. data/include/rbs/location.h +25 -44
  86. data/include/rbs/parser.h +2 -2
  87. data/include/rbs/util/rbs_constant_pool.h +0 -3
  88. data/include/rbs.h +8 -0
  89. data/lib/rbs/ast/ruby/annotations.rb +157 -4
  90. data/lib/rbs/ast/ruby/members.rb +374 -22
  91. data/lib/rbs/cli/validate.rb +5 -60
  92. data/lib/rbs/collection/config/lockfile_generator.rb +6 -2
  93. data/lib/rbs/definition_builder.rb +60 -27
  94. data/lib/rbs/errors.rb +0 -11
  95. data/lib/rbs/inline_parser.rb +1 -1
  96. data/lib/rbs/parser_aux.rb +20 -7
  97. data/lib/rbs/prototype/helpers.rb +57 -0
  98. data/lib/rbs/prototype/rb.rb +1 -26
  99. data/lib/rbs/prototype/rbi.rb +1 -20
  100. data/lib/rbs/test/type_check.rb +3 -0
  101. data/lib/rbs/types.rb +62 -52
  102. data/lib/rbs/unit_test/type_assertions.rb +35 -8
  103. data/lib/rbs/version.rb +1 -1
  104. data/lib/rbs.rb +0 -1
  105. data/rbs.gemspec +1 -1
  106. data/rust/.gitignore +1 -0
  107. data/rust/Cargo.lock +378 -0
  108. data/rust/Cargo.toml +7 -0
  109. data/rust/ruby-rbs/Cargo.toml +22 -0
  110. data/rust/ruby-rbs/build.rs +764 -0
  111. data/rust/ruby-rbs/examples/locations.rs +60 -0
  112. data/rust/ruby-rbs/src/lib.rs +1 -0
  113. data/rust/ruby-rbs/src/node/mod.rs +742 -0
  114. data/rust/ruby-rbs/tests/sanity.rs +47 -0
  115. data/rust/ruby-rbs/vendor/rbs/config.yml +1 -0
  116. data/rust/ruby-rbs-sys/Cargo.toml +23 -0
  117. data/rust/ruby-rbs-sys/build.rs +204 -0
  118. data/rust/ruby-rbs-sys/src/lib.rs +50 -0
  119. data/rust/ruby-rbs-sys/vendor/rbs/include +1 -0
  120. data/rust/ruby-rbs-sys/vendor/rbs/src +1 -0
  121. data/rust/ruby-rbs-sys/wrapper.h +1 -0
  122. data/sig/ast/ruby/annotations.rbs +191 -4
  123. data/sig/ast/ruby/members.rbs +21 -1
  124. data/sig/cli/validate.rbs +1 -6
  125. data/sig/definition_builder.rbs +2 -0
  126. data/sig/errors.rbs +0 -8
  127. data/sig/method_types.rbs +1 -1
  128. data/sig/parser.rbs +17 -13
  129. data/sig/prototype/helpers.rbs +2 -0
  130. data/sig/types.rbs +10 -11
  131. data/sig/unit_test/spy.rbs +0 -8
  132. data/sig/unit_test/type_assertions.rbs +11 -0
  133. data/src/ast.c +339 -161
  134. data/src/lexstate.c +1 -1
  135. data/src/location.c +7 -47
  136. data/src/parser.c +674 -480
  137. data/src/util/rbs_constant_pool.c +0 -4
  138. data/stdlib/bigdecimal/0/big_decimal.rbs +16 -16
  139. data/stdlib/cgi-escape/0/escape.rbs +4 -4
  140. data/stdlib/coverage/0/coverage.rbs +4 -3
  141. data/stdlib/date/0/date.rbs +33 -28
  142. data/stdlib/date/0/date_time.rbs +24 -23
  143. data/stdlib/did_you_mean/0/did_you_mean.rbs +17 -16
  144. data/stdlib/erb/0/erb.rbs +64 -53
  145. data/stdlib/etc/0/etc.rbs +55 -50
  146. data/stdlib/fileutils/0/fileutils.rbs +138 -125
  147. data/stdlib/forwardable/0/forwardable.rbs +10 -10
  148. data/stdlib/io-console/0/io-console.rbs +2 -2
  149. data/stdlib/json/0/json.rbs +135 -108
  150. data/stdlib/monitor/0/monitor.rbs +3 -3
  151. data/stdlib/net-http/0/net-http.rbs +159 -134
  152. data/stdlib/objspace/0/objspace.rbs +8 -7
  153. data/stdlib/open-uri/0/open-uri.rbs +8 -8
  154. data/stdlib/open3/0/open3.rbs +36 -35
  155. data/stdlib/openssl/0/openssl.rbs +144 -129
  156. data/stdlib/optparse/0/optparse.rbs +18 -14
  157. data/stdlib/pathname/0/pathname.rbs +2 -2
  158. data/stdlib/pp/0/pp.rbs +9 -8
  159. data/stdlib/prettyprint/0/prettyprint.rbs +7 -7
  160. data/stdlib/pstore/0/pstore.rbs +35 -30
  161. data/stdlib/psych/0/psych.rbs +61 -8
  162. data/stdlib/psych/0/store.rbs +2 -4
  163. data/stdlib/pty/0/pty.rbs +9 -6
  164. data/stdlib/random-formatter/0/random-formatter.rbs +2 -2
  165. data/stdlib/ripper/0/ripper.rbs +20 -17
  166. data/stdlib/securerandom/0/securerandom.rbs +1 -1
  167. data/stdlib/shellwords/0/shellwords.rbs +2 -2
  168. data/stdlib/socket/0/addrinfo.rbs +7 -7
  169. data/stdlib/socket/0/basic_socket.rbs +3 -3
  170. data/stdlib/socket/0/ip_socket.rbs +10 -8
  171. data/stdlib/socket/0/socket.rbs +10 -9
  172. data/stdlib/socket/0/tcp_server.rbs +1 -1
  173. data/stdlib/socket/0/tcp_socket.rbs +1 -1
  174. data/stdlib/socket/0/udp_socket.rbs +1 -1
  175. data/stdlib/socket/0/unix_server.rbs +1 -1
  176. data/stdlib/stringio/0/stringio.rbs +55 -54
  177. data/stdlib/strscan/0/string_scanner.rbs +46 -44
  178. data/stdlib/tempfile/0/tempfile.rbs +24 -20
  179. data/stdlib/time/0/time.rbs +7 -5
  180. data/stdlib/tsort/0/tsort.rbs +7 -6
  181. data/stdlib/uri/0/common.rbs +26 -18
  182. data/stdlib/uri/0/file.rbs +2 -2
  183. data/stdlib/uri/0/generic.rbs +2 -2
  184. data/stdlib/uri/0/http.rbs +2 -2
  185. data/stdlib/uri/0/ldap.rbs +2 -2
  186. data/stdlib/uri/0/mailto.rbs +3 -3
  187. data/stdlib/uri/0/rfc2396_parser.rbs +6 -5
  188. data/stdlib/zlib/0/deflate.rbs +4 -3
  189. data/stdlib/zlib/0/gzip_reader.rbs +4 -4
  190. data/stdlib/zlib/0/gzip_writer.rbs +14 -12
  191. data/stdlib/zlib/0/inflate.rbs +1 -1
  192. data/stdlib/zlib/0/need_dict.rbs +1 -1
  193. metadata +23 -5
  194. data/.github/workflows/valgrind.yml +0 -42
data/core/array.rbs CHANGED
@@ -376,10 +376,10 @@
376
376
  # * #find_index (aliased as #index): Returns the index of the first element
377
377
  # that meets a given criterion.
378
378
  # * #hash: Returns the integer hash code.
379
- # * #include?: Returns whether any element `==` a given object.
379
+ # * #include?: Returns whether any element <code>==</code> a given object.
380
380
  # * #length (aliased as #size): Returns the count of elements.
381
- # * #none?: Returns whether no element `==` a given object.
382
- # * #one?: Returns whether exactly one element `==` a given object.
381
+ # * #none?: Returns whether no element <code>==</code> a given object.
382
+ # * #one?: Returns whether exactly one element <code>==</code> a given object.
383
383
  # * #rindex: Returns the index of the last element that meets a given
384
384
  # criterion.
385
385
  #
@@ -387,9 +387,9 @@
387
387
  #
388
388
  # * #<=>: Returns -1, 0, or 1, as `self` is less than, equal to, or greater
389
389
  # than a given object.
390
- # * #==: Returns whether each element in `self` is `==` to the corresponding
391
- # element in a given object.
392
- # * #eql?: Returns whether each element in `self` is `eql?` to the
390
+ # * #==: Returns whether each element in `self` is <code>==</code> to the
391
+ # corresponding element in a given object.
392
+ # * #eql?: Returns whether each element in `self` is <code>eql?</code> to the
393
393
  # corresponding element in a given object.
394
394
  #
395
395
  # ### Methods for Fetching
@@ -399,7 +399,7 @@
399
399
  # * #[] (aliased as #slice): Returns consecutive elements as determined by a
400
400
  # given argument.
401
401
  # * #assoc: Returns the first element that is an array whose first element
402
- # `==` a given object.
402
+ # <code>==</code> a given object.
403
403
  # * #at: Returns the element at a given offset.
404
404
  # * #bsearch: Returns an element selected via a binary search as determined by
405
405
  # a given block.
@@ -414,14 +414,14 @@
414
414
  # * #fetch_values: Returns elements at given offsets.
415
415
  # * #first: Returns one or more leading elements.
416
416
  # * #last: Returns one or more trailing elements.
417
- # * #max: Returns one or more maximum-valued elements, as determined by `#<=>`
418
- # or a given block.
419
- # * #min: Returns one or more minimum-valued elements, as determined by `#<=>`
420
- # or a given block.
417
+ # * #max: Returns one or more maximum-valued elements, as determined by
418
+ # <code>#<=></code> or a given block.
419
+ # * #min: Returns one or more minimum-valued elements, as determined by
420
+ # <code>#<=></code> or a given block.
421
421
  # * #minmax: Returns the minimum-valued and maximum-valued elements, as
422
- # determined by `#<=>` or a given block.
422
+ # determined by <code>#<=></code> or a given block.
423
423
  # * #rassoc: Returns the first element that is an array whose second element
424
- # `==` a given object.
424
+ # <code>==</code> a given object.
425
425
  # * #reject: Returns an array containing elements not rejected by a given
426
426
  # block.
427
427
  # * #reverse: Returns all elements in reverse order.
@@ -430,8 +430,8 @@
430
430
  # * #select (aliased as #filter): Returns an array containing elements
431
431
  # selected by a given block.
432
432
  # * #shuffle: Returns elements in a random order.
433
- # * #sort: Returns all elements in an order determined by `#<=>` or a given
434
- # block.
433
+ # * #sort: Returns all elements in an order determined by <code>#<=></code> or
434
+ # a given block.
435
435
  # * #take: Returns leading elements as determined by a given index.
436
436
  # * #take_while: Returns leading elements as determined by a given block.
437
437
  # * #uniq: Returns an array containing non-duplicate elements.
@@ -455,8 +455,8 @@
455
455
  # * #reverse!: Replaces `self` with its elements reversed.
456
456
  # * #rotate!: Replaces `self` with its elements rotated.
457
457
  # * #shuffle!: Replaces `self` with its elements in random order.
458
- # * #sort!: Replaces `self` with its elements sorted, as determined by `#<=>`
459
- # or a given block.
458
+ # * #sort!: Replaces `self` with its elements sorted, as determined by
459
+ # <code>#<=></code> or a given block.
460
460
  # * #sort_by!: Replaces `self` with its elements sorted, as determined by a
461
461
  # given block.
462
462
  # * #unshift (aliased as #prepend): Prepends leading elements.
@@ -539,10 +539,11 @@
539
539
  # * With integer argument `n`, a new array that is the concatenation of
540
540
  # `n` copies of `self`.
541
541
  # * With string argument `field_separator`, a new string that is
542
- # equivalent to `join(field_separator)`.
542
+ # equivalent to <code>join(field_separator)</code>.
543
543
  #
544
544
  # * #pack: Packs the elements into a binary sequence.
545
- # * #sum: Returns a sum of elements according to either `+` or a given block.
545
+ # * #sum: Returns a sum of elements according to either <code>+</code> or a
546
+ # given block.
546
547
  #
547
548
  %a{annotate:rdoc:source:from=array.c}
548
549
  class Array[unchecked out Elem] < Object
@@ -574,8 +575,8 @@ class Array[unchecked out Elem] < Object
574
575
  # Array.new(2, 3) # => [3, 3]
575
576
  #
576
577
  # With a block given, returns an array of the given `size`; calls the block with
577
- # each `index` in the range `(0...size)`; the element at that `index` in the
578
- # returned array is the blocks return value:
578
+ # each `index` in the range <code>(0...size)</code>; the element at that `index`
579
+ # in the returned array is the blocks return value:
579
580
  #
580
581
  # Array.new(3) {|index| "Element #{index}" } # => ["Element 0", "Element 1", "Element 2"]
581
582
  #
@@ -630,9 +631,9 @@ class Array[unchecked out Elem] < Object
630
631
  #
631
632
  # If `object` is an array, returns `object`.
632
633
  #
633
- # Otherwise if `object` responds to `:to_ary`. calls `object.to_ary`: if the
634
- # return value is an array or `nil`, returns that value; if not, raises
635
- # TypeError.
634
+ # Otherwise if `object` responds to <code>:to_ary</code>. calls
635
+ # <code>object.to_ary</code>: if the return value is an array or `nil`, returns
636
+ # that value; if not, raises TypeError.
636
637
  #
637
638
  # Otherwise returns `nil`.
638
639
  #
@@ -658,8 +659,8 @@ class Array[unchecked out Elem] < Object
658
659
  #
659
660
  # [0, 1, 2] & [3, 2, 1, 0] # => [0, 1, 2]
660
661
  #
661
- # Identifies common elements using method `#eql?` (as defined in each element of
662
- # `self`).
662
+ # Identifies common elements using method <code>#eql?</code> (as defined in each
663
+ # element of `self`).
663
664
  #
664
665
  # Related: see [Methods for Combining](rdoc-ref:Array@Methods+for+Combining).
665
666
  #
@@ -677,7 +678,7 @@ class Array[unchecked out Elem] < Object
677
678
  # a * 3 # => ["x", "y", "x", "y", "x", "y"]
678
679
  #
679
680
  # When string argument `string_separator` is given, equivalent to
680
- # `self.join(string_separator)`:
681
+ # <code>self.join(string_separator)</code>:
681
682
  #
682
683
  # [0, [0, 1], {foo: 0}] * ', ' # => "0, 0, 1, {foo: 0}"
683
684
  #
@@ -709,8 +710,8 @@ class Array[unchecked out Elem] < Object
709
710
  # [0, 1, 1, 2, 1, 1, 3, 1, 1] - [3, 2, 0, :foo] # => [1, 1, 1, 1, 1, 1]
710
711
  # [0, 1, 2] - [:foo] # => [0, 1, 2]
711
712
  #
712
- # Element are compared using method `#eql?` (as defined in each element of
713
- # `self`).
713
+ # Element are compared using method <code>#eql?</code> (as defined in each
714
+ # element of `self`).
714
715
  #
715
716
  # Related: see [Methods for Combining](rdoc-ref:Array@Methods+for+Combining).
716
717
  #
@@ -739,21 +740,22 @@ class Array[unchecked out Elem] < Object
739
740
  # Returns -1, 0, or 1 as `self` is determined to be less than, equal to, or
740
741
  # greater than `other_array`.
741
742
  #
742
- # Iterates over each index `i` in `(0...self.size)`:
743
+ # Iterates over each index `i` in <code>(0...self.size)</code>:
743
744
  #
744
- # * Computes `result[i]` as `self[i] <=> other_array[i]`.
745
- # * Immediately returns 1 if `result[i]` is 1:
745
+ # * Computes <code>result[i]</code> as <code>self[i] <=>
746
+ # other_array[i]</code>.
747
+ # * Immediately returns 1 if <code>result[i]</code> is 1:
746
748
  #
747
749
  # [0, 1, 2] <=> [0, 0, 2] # => 1
748
750
  #
749
- # * Immediately returns -1 if `result[i]` is -1:
751
+ # * Immediately returns -1 if <code>result[i]</code> is -1:
750
752
  #
751
753
  # [0, 1, 2] <=> [0, 2, 2] # => -1
752
754
  #
753
- # * Continues if `result[i]` is 0.
755
+ # * Continues if <code>result[i]</code> is 0.
754
756
  #
755
- # When every `result` is 0, returns `self.size <=> other_array.size` (see
756
- # Integer#<=>):
757
+ # When every `result` is 0, returns <code>self.size <=> other_array.size</code>
758
+ # (see Integer#<=>):
757
759
  #
758
760
  # [0, 1, 2] <=> [0, 1] # => 1
759
761
  # [0, 1, 2] <=> [0, 1, 2] # => 0
@@ -778,7 +780,7 @@ class Array[unchecked out Elem] < Object
778
780
  #
779
781
  # * `self` and `other_array` are the same size.
780
782
  # * Their corresponding elements are the same; that is, for each index `i` in
781
- # `(0...self.size)`, `self[i] == other_array[i]`.
783
+ # <code>(0...self.size)</code>, <code>self[i] == other_array[i]</code>.
782
784
  #
783
785
  # Examples:
784
786
  #
@@ -788,7 +790,7 @@ class Array[unchecked out Elem] < Object
788
790
  # [:foo, 'bar', 2] == [:foo, 'bar', 3] # => false # Different elements.
789
791
  #
790
792
  # This method is different from method Array#eql?, which compares elements using
791
- # `Object#eql?`.
793
+ # <code>Object#eql?</code>.
792
794
  #
793
795
  # Related: see [Methods for Comparing](rdoc-ref:Array@Methods+for+Comparing).
794
796
  #
@@ -847,42 +849,45 @@ class Array[unchecked out Elem] < Object
847
849
  # a[0, 2] # => [:foo, "bar"]
848
850
  # a[1, 2] # => ["bar", 2]
849
851
  #
850
- # If `start + length` is greater than `self.length`, returns all elements from
851
- # offset `start` to the end:
852
+ # If <code>start + length</code> is greater than <code>self.length</code>,
853
+ # returns all elements from offset `start` to the end:
852
854
  #
853
855
  # a = [:foo, 'bar', 2]
854
856
  # a[0, 4] # => [:foo, "bar", 2]
855
857
  # a[1, 3] # => ["bar", 2]
856
858
  # a[2, 2] # => [2]
857
859
  #
858
- # If `start == self.size` and `length >= 0`, returns a new empty array.
860
+ # If <code>start == self.size</code> and <code>length >= 0</code>, returns a new
861
+ # empty array.
859
862
  #
860
863
  # If `length` is negative, returns `nil`.
861
864
  #
862
- # When a single Range argument `range` is given, treats `range.min` as `start`
863
- # above and `range.size` as `length` above:
865
+ # When a single Range argument `range` is given, treats <code>range.min</code>
866
+ # as `start` above and <code>range.size</code> as `length` above:
864
867
  #
865
868
  # a = [:foo, 'bar', 2]
866
869
  # a[0..1] # => [:foo, "bar"]
867
870
  # a[1..2] # => ["bar", 2]
868
871
  #
869
- # Special case: If `range.start == a.size`, returns a new empty array.
872
+ # Special case: If <code>range.start == a.size</code>, returns a new empty
873
+ # array.
870
874
  #
871
- # If `range.end` is negative, calculates the end index from the end:
875
+ # If <code>range.end</code> is negative, calculates the end index from the end:
872
876
  #
873
877
  # a = [:foo, 'bar', 2]
874
878
  # a[0..-1] # => [:foo, "bar", 2]
875
879
  # a[0..-2] # => [:foo, "bar"]
876
880
  # a[0..-3] # => [:foo]
877
881
  #
878
- # If `range.start` is negative, calculates the start index from the end:
882
+ # If <code>range.start</code> is negative, calculates the start index from the
883
+ # end:
879
884
  #
880
885
  # a = [:foo, 'bar', 2]
881
886
  # a[-1..2] # => [2]
882
887
  # a[-2..2] # => ["bar", 2]
883
888
  # a[-3..2] # => [:foo, "bar", 2]
884
889
  #
885
- # If `range.start` is larger than the array size, returns `nil`.
890
+ # If <code>range.start</code> is larger than the array size, returns `nil`.
886
891
  #
887
892
  # a = [:foo, 'bar', 2]
888
893
  # a[4..1] # => nil
@@ -962,7 +967,7 @@ class Array[unchecked out Elem] < Object
962
967
  # a[0] = 'foo' # => "foo"
963
968
  # a # => ["foo", "bar", 2]
964
969
  #
965
- # If `index` is greater than `self.length`, extends the array:
970
+ # If `index` is greater than <code>self.length</code>, extends the array:
966
971
  #
967
972
  # a = [:foo, 'bar', 2]
968
973
  # a[7] = 'foo' # => "foo"
@@ -975,8 +980,8 @@ class Array[unchecked out Elem] < Object
975
980
  # a # => [:foo, "bar", "two"]
976
981
  #
977
982
  # When Integer arguments `start` and `length` are given and `object` is not an
978
- # array, removes `length - 1` elements beginning at offset `start`, and assigns
979
- # `object` at offset `start`:
983
+ # array, removes <code>length - 1</code> elements beginning at offset `start`,
984
+ # and assigns `object` at offset `start`:
980
985
  #
981
986
  # a = [:foo, 'bar', 2]
982
987
  # a[0, 2] = 'foo' # => "foo"
@@ -988,8 +993,8 @@ class Array[unchecked out Elem] < Object
988
993
  # a[-2, 2] = 'foo' # => "foo"
989
994
  # a # => [:foo, "foo"]
990
995
  #
991
- # If `start` is non-negative and outside the array (` >= self.size`), extends
992
- # the array with `nil`, assigns `object` at offset `start`, and ignores
996
+ # If `start` is non-negative and outside the array (<code> >= self.size</code>),
997
+ # extends the array with `nil`, assigns `object` at offset `start`, and ignores
993
998
  # `length`:
994
999
  #
995
1000
  # a = [:foo, 'bar', 2]
@@ -1010,35 +1015,38 @@ class Array[unchecked out Elem] < Object
1010
1015
  # a # => [:foo, "foo"]
1011
1016
  #
1012
1017
  # When Range argument `range` is given and `object` is not an array, removes
1013
- # `length - 1` elements beginning at offset `start`, and assigns `object` at
1014
- # offset `start`:
1018
+ # <code>length - 1</code> elements beginning at offset `start`, and assigns
1019
+ # `object` at offset `start`:
1015
1020
  #
1016
1021
  # a = [:foo, 'bar', 2]
1017
1022
  # a[0..1] = 'foo' # => "foo"
1018
1023
  # a # => ["foo", 2]
1019
1024
  #
1020
- # if `range.begin` is negative, counts backwards from the end of the array:
1025
+ # if <code>range.begin</code> is negative, counts backwards from the end of the
1026
+ # array:
1021
1027
  #
1022
1028
  # a = [:foo, 'bar', 2]
1023
1029
  # a[-2..2] = 'foo' # => "foo"
1024
1030
  # a # => [:foo, "foo"]
1025
1031
  #
1026
- # If the array length is less than `range.begin`, extends the array with `nil`,
1027
- # assigns `object` at offset `range.begin`, and ignores `length`:
1032
+ # If the array length is less than <code>range.begin</code>, extends the array
1033
+ # with `nil`, assigns `object` at offset <code>range.begin</code>, and ignores
1034
+ # `length`:
1028
1035
  #
1029
1036
  # a = [:foo, 'bar', 2]
1030
1037
  # a[6..50] = 'foo' # => "foo"
1031
1038
  # a # => [:foo, "bar", 2, nil, nil, nil, "foo"]
1032
1039
  #
1033
- # If `range.end` is zero, shifts elements at and following offset `start` and
1034
- # assigns `object` at offset `start`:
1040
+ # If <code>range.end</code> is zero, shifts elements at and following offset
1041
+ # `start` and assigns `object` at offset `start`:
1035
1042
  #
1036
1043
  # a = [:foo, 'bar', 2]
1037
1044
  # a[1..0] = 'foo' # => "foo"
1038
1045
  # a # => [:foo, "foo", "bar", 2]
1039
1046
  #
1040
- # If `range.end` is negative, assigns `object` at offset `start`, retains
1041
- # `range.end.abs -1` elements past that, and removes those beyond:
1047
+ # If <code>range.end</code> is negative, assigns `object` at offset `start`,
1048
+ # retains <code>range.end.abs -1</code> elements past that, and removes those
1049
+ # beyond:
1042
1050
  #
1043
1051
  # a = [:foo, 'bar', 2]
1044
1052
  # a[1..-1] = 'foo' # => "foo"
@@ -1051,8 +1059,8 @@ class Array[unchecked out Elem] < Object
1051
1059
  # a # => [:foo, "foo", "bar", 2]
1052
1060
  # a = [:foo, 'bar', 2]
1053
1061
  #
1054
- # If `range.end` is too large for the existing array, replaces array elements,
1055
- # but does not extend the array with `nil` values:
1062
+ # If <code>range.end</code> is too large for the existing array, replaces array
1063
+ # elements, but does not extend the array with `nil` values:
1056
1064
  #
1057
1065
  # a = [:foo, 'bar', 2]
1058
1066
  # a[1..5] = 'foo' # => "foo"
@@ -1083,8 +1091,8 @@ class Array[unchecked out Elem] < Object
1083
1091
  # [[], {}, '', 0, 0.0, nil].all? # => false # nil is not truthy.
1084
1092
  # [[], {}, '', 0, 0.0, false].all? # => false # false is not truthy.
1085
1093
  #
1086
- # With argument `object` given, returns whether `object === ele` for every
1087
- # element `ele` in `self`:
1094
+ # With argument `object` given, returns whether <code>object === ele</code> for
1095
+ # every element `ele` in `self`:
1088
1096
  #
1089
1097
  # [0, 0, 0].all?(0) # => true
1090
1098
  # [0, 1, 2].all?(1) # => false
@@ -1125,8 +1133,8 @@ class Array[unchecked out Elem] < Object
1125
1133
  # [nil, false, ''].any? # => true # String object is truthy.
1126
1134
  # [nil, false].any? # => false # Nil and false are not truthy.
1127
1135
  #
1128
- # With argument `object` given, returns whether `object === ele` for any element
1129
- # `ele` in `self`:
1136
+ # With argument `object` given, returns whether <code>object === ele</code> for
1137
+ # any element `ele` in `self`:
1130
1138
  #
1131
1139
  # [nil, false, 0].any?(0) # => true
1132
1140
  # [nil, false, 1].any?(0) # => false
@@ -1169,7 +1177,7 @@ class Array[unchecked out Elem] < Object
1169
1177
  # - assoc(object) -> found_array or nil
1170
1178
  # -->
1171
1179
  # Returns the first element `ele` in `self` such that `ele` is an array and
1172
- # `ele[0] == object`:
1180
+ # <code>ele[0] == object</code>:
1173
1181
  #
1174
1182
  # a = [{foo: 0}, [2, 4], [4, 5, 6], [4, 5]]
1175
1183
  # a.assoc(4) # => [4, 5, 6]
@@ -1299,8 +1307,8 @@ class Array[unchecked out Elem] < Object
1299
1307
  # -->
1300
1308
  # When a block and a positive [integer-convertible
1301
1309
  # object](rdoc-ref:implicit_conversion.rdoc@Integer-Convertible+Objects)
1302
- # argument `count` (`0 < count <= self.size`) are given, calls the block with
1303
- # each combination of `self` of size `count`; returns `self`:
1310
+ # argument `count` (<code>0 < count <= self.size</code>) are given, calls the
1311
+ # block with each combination of `self` of size `count`; returns `self`:
1304
1312
  #
1305
1313
  # a = %w[a b c] # => ["a", "b", "c"]
1306
1314
  # a.combination(2) {|combination| p combination } # => ["a", "b", "c"]
@@ -1323,8 +1331,8 @@ class Array[unchecked out Elem] < Object
1323
1331
  # []
1324
1332
  # []
1325
1333
  #
1326
- # When `count` is negative or larger than `self.size` and `self` is non-empty,
1327
- # does not call the block:
1334
+ # When `count` is negative or larger than <code>self.size</code> and `self` is
1335
+ # non-empty, does not call the block:
1328
1336
  #
1329
1337
  # a.combination(-1) {|combination| fail 'Cannot happen' } # => ["a", "b", "c"]
1330
1338
  # a.combination(4) {|combination| fail 'Cannot happen' } # => ["a", "b", "c"]
@@ -1395,7 +1403,8 @@ class Array[unchecked out Elem] < Object
1395
1403
  #
1396
1404
  # [0, :one, 'two', 3, 3.0].count # => 5
1397
1405
  #
1398
- # With argument `object` given, returns the count of elements `==` to `object`:
1406
+ # With argument `object` given, returns the count of elements <code>==</code> to
1407
+ # `object`:
1399
1408
  #
1400
1409
  # [0, :one, 'two', 3, 3.0].count(3) # => 2
1401
1410
  #
@@ -1405,7 +1414,7 @@ class Array[unchecked out Elem] < Object
1405
1414
  # [0, 1, 2, 3].count {|element| element > 1 } # => 2
1406
1415
  #
1407
1416
  # With argument `object` and a block given, issues a warning, ignores the block,
1408
- # and returns the count of elements `==` to `object`.
1417
+ # and returns the count of elements <code>==</code> to `object`.
1409
1418
  #
1410
1419
  # Related: see [Methods for Querying](rdoc-ref:Array@Methods+for+Querying).
1411
1420
  #
@@ -1462,8 +1471,8 @@ class Array[unchecked out Elem] < Object
1462
1471
  # -->
1463
1472
  # Removes zero or more elements from `self`.
1464
1473
  #
1465
- # With no block given, removes from `self` each element `ele` such that `ele ==
1466
- # object`; returns the last removed element:
1474
+ # With no block given, removes from `self` each element `ele` such that
1475
+ # <code>ele == object</code>; returns the last removed element:
1467
1476
  #
1468
1477
  # a = [0, 1, 2, 2.0]
1469
1478
  # a.delete(2) # => 2.0
@@ -1473,8 +1482,8 @@ class Array[unchecked out Elem] < Object
1473
1482
  #
1474
1483
  # a.delete(2) # => nil
1475
1484
  #
1476
- # With a block given, removes from `self` each element `ele` such that `ele ==
1477
- # object`.
1485
+ # With a block given, removes from `self` each element `ele` such that <code>ele
1486
+ # == object</code>.
1478
1487
  #
1479
1488
  # If any such elements are found, ignores the block and returns the last removed
1480
1489
  # element:
@@ -1546,8 +1555,8 @@ class Array[unchecked out Elem] < Object
1546
1555
  # - difference(*other_arrays = []) -> new_array
1547
1556
  # -->
1548
1557
  # Returns a new array containing only those elements from `self` that are not
1549
- # found in any of the given `other_arrays`; items are compared using `eql?`;
1550
- # order from `self` is preserved:
1558
+ # found in any of the given `other_arrays`; items are compared using
1559
+ # <code>eql?</code>; order from `self` is preserved:
1551
1560
  #
1552
1561
  # [0, 1, 1, 2, 1, 1, 3, 1, 1].difference([1]) # => [0, 2, 3]
1553
1562
  # [0, 1, 2, 3].difference([3, 0], [1, 3]) # => [2]
@@ -1705,7 +1714,7 @@ class Array[unchecked out Elem] < Object
1705
1714
  # - eql?(other_array) -> true or false
1706
1715
  # -->
1707
1716
  # Returns `true` if `self` and `other_array` are the same size, and if, for each
1708
- # index `i` in `self`, `self[i].eql?(other_array[i])`:
1717
+ # index `i` in `self`, <code>self[i].eql?(other_array[i])</code>:
1709
1718
  #
1710
1719
  # a0 = [:foo, 'bar', 2]
1711
1720
  # a1 = [:foo, 'bar', 2]
@@ -1714,7 +1723,7 @@ class Array[unchecked out Elem] < Object
1714
1723
  # Otherwise, returns `false`.
1715
1724
  #
1716
1725
  # This method is different from method Array#==, which compares using method
1717
- # `Object#==`.
1726
+ # <code>Object#==</code>.
1718
1727
  #
1719
1728
  # Related: see [Methods for Querying](rdoc-ref:Array@Methods+for+Querying).
1720
1729
  #
@@ -2055,7 +2064,7 @@ class Array[unchecked out Elem] < Object
2055
2064
  # Returns the zero-based integer index of a specified element, or `nil`.
2056
2065
  #
2057
2066
  # With only argument `object` given, returns the index of the first element
2058
- # `element` for which `object == element`:
2067
+ # `element` for which <code>object == element</code>:
2059
2068
  #
2060
2069
  # a = [:foo, 'bar', 2, 'bar']
2061
2070
  # a.index('bar') # => 1
@@ -2197,7 +2206,8 @@ class Array[unchecked out Elem] < Object
2197
2206
  # rdoc-file=array.c
2198
2207
  # - include?(object) -> true or false
2199
2208
  # -->
2200
- # Returns whether for some element `element` in `self`, `object == element`:
2209
+ # Returns whether for some element `element` in `self`, <code>object ==
2210
+ # element</code>:
2201
2211
  #
2202
2212
  # [0, 1, 2].include?(2) # => true
2203
2213
  # [0, 1, 2].include?(2.0) # => true
@@ -2205,13 +2215,13 @@ class Array[unchecked out Elem] < Object
2205
2215
  #
2206
2216
  # Related: see [Methods for Querying](rdoc-ref:Array@Methods+for+Querying).
2207
2217
  #
2208
- def include?: (Elem object) -> bool
2218
+ def include?: (top object) -> bool
2209
2219
 
2210
2220
  # <!-- rdoc-file=array.c -->
2211
2221
  # Returns the zero-based integer index of a specified element, or `nil`.
2212
2222
  #
2213
2223
  # With only argument `object` given, returns the index of the first element
2214
- # `element` for which `object == element`:
2224
+ # `element` for which <code>object == element</code>:
2215
2225
  #
2216
2226
  # a = [:foo, 'bar', 2, 'bar']
2217
2227
  # a.index('bar') # => 1
@@ -2244,13 +2254,14 @@ class Array[unchecked out Elem] < Object
2244
2254
  # a = ['a', 'b', 'c'] # => ["a", "b", "c"]
2245
2255
  # a.insert(1, :x, :y, :z) # => ["a", :x, :y, :z, "b", "c"]
2246
2256
  #
2247
- # Extends the array if `index` is beyond the array (`index >= self.size`):
2257
+ # Extends the array if `index` is beyond the array (<code>index >=
2258
+ # self.size</code>):
2248
2259
  #
2249
2260
  # a = ['a', 'b', 'c'] # => ["a", "b", "c"]
2250
2261
  # a.insert(5, :x, :y, :z) # => ["a", "b", "c", nil, nil, :x, :y, :z]
2251
2262
  #
2252
2263
  # When `index` is negative, inserts `objects` *after* the element at offset
2253
- # `index + self.size`:
2264
+ # <code>index + self.size</code>:
2254
2265
  #
2255
2266
  # a = ['a', 'b', 'c'] # => ["a", "b", "c"]
2256
2267
  # a.insert(-2, :x, :y, :z) # => ["a", "b", :x, :y, :z, "c"]
@@ -2274,8 +2285,8 @@ class Array[unchecked out Elem] < Object
2274
2285
  # - inspect -> new_string
2275
2286
  # - to_s -> new_string
2276
2287
  # -->
2277
- # Returns the new string formed by calling method `#inspect` on each array
2278
- # element:
2288
+ # Returns the new string formed by calling method <code>#inspect</code> on each
2289
+ # array element:
2279
2290
  #
2280
2291
  # a = [:foo, 'bar', 2]
2281
2292
  # a.inspect # => "[:foo, \"bar\", 2]"
@@ -2288,13 +2299,13 @@ class Array[unchecked out Elem] < Object
2288
2299
  # rdoc-file=array.c
2289
2300
  # - intersect?(other_array) -> true or false
2290
2301
  # -->
2291
- # Returns whether `other_array` has at least one element that is `#eql?` to some
2292
- # element of `self`:
2302
+ # Returns whether `other_array` has at least one element that is
2303
+ # <code>#eql?</code> to some element of `self`:
2293
2304
  #
2294
2305
  # [1, 2, 3].intersect?([3, 4, 5]) # => true
2295
2306
  # [1, 2, 3].intersect?([4, 5, 6]) # => false
2296
2307
  #
2297
- # Each element must correctly implement method `#hash`.
2308
+ # Each element must correctly implement method <code>#hash</code>.
2298
2309
  #
2299
2310
  # Related: see [Methods for Querying](rdoc-ref:Array@Methods+for+Querying).
2300
2311
  #
@@ -2304,12 +2315,13 @@ class Array[unchecked out Elem] < Object
2304
2315
  # rdoc-file=array.c
2305
2316
  # - intersection(*other_arrays) -> new_array
2306
2317
  # -->
2307
- # Returns a new array containing each element in `self` that is `#eql?` to at
2308
- # least one element in each of the given `other_arrays`; duplicates are omitted:
2318
+ # Returns a new array containing each element in `self` that is
2319
+ # <code>#eql?</code> to at least one element in each of the given
2320
+ # `other_arrays`; duplicates are omitted:
2309
2321
  #
2310
2322
  # [0, 0, 1, 1, 2, 3].intersection([0, 1, 2], [0, 1, 3]) # => [0, 1]
2311
2323
  #
2312
- # Each element must correctly implement method `#hash`.
2324
+ # Each element must correctly implement method <code>#hash</code>.
2313
2325
  #
2314
2326
  # Order from `self` is preserved:
2315
2327
  #
@@ -2328,11 +2340,12 @@ class Array[unchecked out Elem] < Object
2328
2340
  # Returns the new string formed by joining the converted elements of `self`; for
2329
2341
  # each element `element`:
2330
2342
  #
2331
- # * Converts recursively using `element.join(separator)` if `element` is a
2332
- # `kind_of?(Array)`.
2333
- # * Otherwise, converts using `element.to_s`.
2343
+ # * Converts recursively using <code>element.join(separator)</code> if
2344
+ # `element` is a <code>kind_of?(Array)</code>.
2345
+ # * Otherwise, converts using <code>element.to_s</code>.
2334
2346
  #
2335
- # With no argument given, joins using the output field separator, `$,`:
2347
+ # With no argument given, joins using the output field separator,
2348
+ # <code>$,</code>:
2336
2349
  #
2337
2350
  # a = [:foo, 'bar', 2]
2338
2351
  # $, # => nil
@@ -2455,16 +2468,17 @@ class Array[unchecked out Elem] < Object
2455
2468
  #
2456
2469
  # Does not modify `self`.
2457
2470
  #
2458
- # With no block given, each element in `self` must respond to method `#<=>` with
2459
- # a numeric.
2471
+ # With no block given, each element in `self` must respond to method
2472
+ # <code>#<=></code> with a numeric.
2460
2473
  #
2461
2474
  # With no argument and no block, returns the element in `self` having the
2462
- # maximum value per method `#<=>`:
2475
+ # maximum value per method <code>#<=></code>:
2463
2476
  #
2464
2477
  # [1, 0, 3, 2].max # => 3
2465
2478
  #
2466
2479
  # With non-negative numeric argument `count` and no block, returns a new array
2467
- # with at most `count` elements, in descending order, per method `#<=>`:
2480
+ # with at most `count` elements, in descending order, per method
2481
+ # <code>#<=></code>:
2468
2482
  #
2469
2483
  # [1, 0, 3, 2].max(3) # => [3, 2, 1]
2470
2484
  # [1, 0, 3, 2].max(3.0) # => [3, 2, 1]
@@ -2473,8 +2487,9 @@ class Array[unchecked out Elem] < Object
2473
2487
  #
2474
2488
  # With a block given, the block must return a numeric.
2475
2489
  #
2476
- # With a block and no argument, calls the block `self.size - 1` times to compare
2477
- # elements; returns the element having the maximum value per the block:
2490
+ # With a block and no argument, calls the block <code>self.size - 1</code> times
2491
+ # to compare elements; returns the element having the maximum value per the
2492
+ # block:
2478
2493
  #
2479
2494
  # ['0', '', '000', '00'].max {|a, b| a.size <=> b.size }
2480
2495
  # # => "000"
@@ -2506,16 +2521,17 @@ class Array[unchecked out Elem] < Object
2506
2521
  #
2507
2522
  # Does not modify `self`.
2508
2523
  #
2509
- # With no block given, each element in `self` must respond to method `#<=>` with
2510
- # a numeric.
2524
+ # With no block given, each element in `self` must respond to method
2525
+ # <code>#<=></code> with a numeric.
2511
2526
  #
2512
2527
  # With no argument and no block, returns the element in `self` having the
2513
- # minimum value per method `#<=>`:
2528
+ # minimum value per method <code>#<=></code>:
2514
2529
  #
2515
2530
  # [1, 0, 3, 2].min # => 0
2516
2531
  #
2517
2532
  # With non-negative numeric argument `count` and no block, returns a new array
2518
- # with at most `count` elements, in ascending order, per method `#<=>`:
2533
+ # with at most `count` elements, in ascending order, per method
2534
+ # <code>#<=></code>:
2519
2535
  #
2520
2536
  # [1, 0, 3, 2].min(3) # => [0, 1, 2]
2521
2537
  # [1, 0, 3, 2].min(3.0) # => [0, 1, 2]
@@ -2524,8 +2540,9 @@ class Array[unchecked out Elem] < Object
2524
2540
  #
2525
2541
  # With a block given, the block must return a numeric.
2526
2542
  #
2527
- # With a block and no argument, calls the block `self.size - 1` times to compare
2528
- # elements; returns the element having the minimum value per the block:
2543
+ # With a block and no argument, calls the block <code>self.size - 1</code> times
2544
+ # to compare elements; returns the element having the minimum value per the
2545
+ # block:
2529
2546
  #
2530
2547
  # ['0', '', '000', '00'].min {|a, b| a.size <=> b.size }
2531
2548
  # # => ""
@@ -2549,13 +2566,13 @@ class Array[unchecked out Elem] < Object
2549
2566
  # elements from `self`; does not modify `self`.
2550
2567
  #
2551
2568
  # With no block given, the minimum and maximum values are determined using
2552
- # method `#<=>`:
2569
+ # method <code>#<=></code>:
2553
2570
  #
2554
2571
  # [1, 0, 3, 2].minmax # => [0, 3]
2555
2572
  #
2556
2573
  # With a block given, the block must return a numeric; the block is called
2557
- # `self.size - 1` times to compare elements; returns the elements having the
2558
- # minimum and maximum values per the block:
2574
+ # <code>self.size - 1</code> times to compare elements; returns the elements
2575
+ # having the minimum and maximum values per the block:
2559
2576
  #
2560
2577
  # ['0', '', '000', '00'].minmax {|a, b| a.size <=> b.size }
2561
2578
  # # => ["", "000"]
@@ -2582,7 +2599,7 @@ class Array[unchecked out Elem] < Object
2582
2599
  # [].none? # => true
2583
2600
  #
2584
2601
  # With argument `object` given, returns `false` if for any element `element`,
2585
- # `object === element`; `true` otherwise:
2602
+ # <code>object === element</code>; `true` otherwise:
2586
2603
  #
2587
2604
  # ['food', 'drink'].none?(/bar/) # => true
2588
2605
  # ['food', 'drink'].none?(/foo/) # => false
@@ -2624,7 +2641,7 @@ class Array[unchecked out Elem] < Object
2624
2641
  # [0, 1, 2].one? {|element| element > 2 } # => false
2625
2642
  #
2626
2643
  # With argument `object` given, returns `true` if for exactly one element
2627
- # `element`, `object === element`; `false` otherwise:
2644
+ # `element`, <code>object === element</code>; `false` otherwise:
2628
2645
  #
2629
2646
  # [0, 1, 2].one?(0) # => true
2630
2647
  # [0, 0, 1].one?(0) # => false
@@ -2654,9 +2671,9 @@ class Array[unchecked out Elem] < Object
2654
2671
  # Iterates over permutations of the elements of `self`; the order of
2655
2672
  # permutations is indeterminate.
2656
2673
  #
2657
- # With a block and an in-range positive integer argument `count` (`0 < count <=
2658
- # self.size`) given, calls the block with each permutation of `self` of size
2659
- # `count`; returns `self`:
2674
+ # With a block and an in-range positive integer argument `count` (<code>0 <
2675
+ # count <= self.size</code>) given, calls the block with each permutation of
2676
+ # `self` of size `count`; returns `self`:
2660
2677
  #
2661
2678
  # a = [0, 1, 2]
2662
2679
  # perms = []
@@ -2677,8 +2694,8 @@ class Array[unchecked out Elem] < Object
2677
2694
  # a.permutation(0) {|perm| perms.push(perm) }
2678
2695
  # perms # => [[]]
2679
2696
  #
2680
- # When `count` is out of range (negative or larger than `self.size`), does not
2681
- # call the block:
2697
+ # When `count` is out of range (negative or larger than <code>self.size</code>),
2698
+ # does not call the block:
2682
2699
  #
2683
2700
  # a.permutation(-1) {|permutation| fail 'Cannot happen' }
2684
2701
  # a.permutation(4) {|permutation| fail 'Cannot happen' }
@@ -2815,7 +2832,7 @@ class Array[unchecked out Elem] < Object
2815
2832
  # - rassoc(object) -> found_array or nil
2816
2833
  # -->
2817
2834
  # Returns the first element `ele` in `self` such that `ele` is an array and
2818
- # `ele[1] == object`:
2835
+ # <code>ele[1] == object</code>:
2819
2836
  #
2820
2837
  # a = [{foo: 0}, [2, 4], [4, 5, 6], [4, 5]]
2821
2838
  # a.rassoc(4) # => [2, 4]
@@ -2879,7 +2896,7 @@ class Array[unchecked out Elem] < Object
2879
2896
  #
2880
2897
  # If a positive integer argument `size` is given, calls the block with each
2881
2898
  # `size`-tuple repeated combination of the elements of `self`. The number of
2882
- # combinations is `(size+1)(size+2)/2`.
2899
+ # combinations is <code>(size+1)(size+2)/2</code>.
2883
2900
  #
2884
2901
  # Examples:
2885
2902
  #
@@ -2919,7 +2936,7 @@ class Array[unchecked out Elem] < Object
2919
2936
  #
2920
2937
  # If a positive integer argument `size` is given, calls the block with each
2921
2938
  # `size`-tuple repeated permutation of the elements of `self`. The number of
2922
- # permutations is `self.size**size`.
2939
+ # permutations is <code>self.size**size</code>.
2923
2940
  #
2924
2941
  # Examples:
2925
2942
  #
@@ -3043,7 +3060,8 @@ class Array[unchecked out Elem] < Object
3043
3060
  # - rindex {|element| ... } -> integer or nil
3044
3061
  # - rindex -> new_enumerator
3045
3062
  # -->
3046
- # Returns the index of the last element for which `object == element`.
3063
+ # Returns the index of the last element for which <code>object ==
3064
+ # element</code>.
3047
3065
  #
3048
3066
  # With argument `object` given, returns the index of the last such element
3049
3067
  # found:
@@ -3082,7 +3100,7 @@ class Array[unchecked out Elem] < Object
3082
3100
  # [0, 1, 2, 3].rotate(2) # => [2, 3, 0, 1]
3083
3101
  # [0, 1, 2, 3].rotate(2.1) # => [2, 3, 0, 1]
3084
3102
  #
3085
- # If `count` is large, uses `count % array.size` as the count:
3103
+ # If `count` is large, uses <code>count % array.size</code> as the count:
3086
3104
  #
3087
3105
  # [0, 1, 2, 3].rotate(22) # => [2, 3, 0, 1]
3088
3106
  #
@@ -3095,7 +3113,8 @@ class Array[unchecked out Elem] < Object
3095
3113
  #
3096
3114
  # [0, 1, 2, 3].rotate(-1) # => [3, 0, 1, 2]
3097
3115
  #
3098
- # If `count` is small (far from zero), uses `count % array.size` as the count:
3116
+ # If `count` is small (far from zero), uses <code>count % array.size</code> as
3117
+ # the count:
3099
3118
  #
3100
3119
  # [0, 1, 2, 3].rotate(-21) # => [3, 0, 1, 2]
3101
3120
  #
@@ -3116,7 +3135,7 @@ class Array[unchecked out Elem] < Object
3116
3135
  # [0, 1, 2, 3].rotate!(2) # => [2, 3, 0, 1]
3117
3136
  # [0, 1, 2, 3].rotate!(2.1) # => [2, 3, 0, 1]
3118
3137
  #
3119
- # If `count` is large, uses `count % array.size` as the count:
3138
+ # If `count` is large, uses <code>count % array.size</code> as the count:
3120
3139
  #
3121
3140
  # [0, 1, 2, 3].rotate!(21) # => [1, 2, 3, 0]
3122
3141
  #
@@ -3129,7 +3148,8 @@ class Array[unchecked out Elem] < Object
3129
3148
  #
3130
3149
  # [0, 1, 2, 3].rotate!(-1) # => [3, 0, 1, 2]
3131
3150
  #
3132
- # If `count` is small (far from zero), uses `count % array.size` as the count:
3151
+ # If `count` is small (far from zero), uses <code>count % array.size</code> as
3152
+ # the count:
3133
3153
  #
3134
3154
  # [0, 1, 2, 3].rotate!(-21) # => [3, 0, 1, 2]
3135
3155
  #
@@ -3172,8 +3192,8 @@ class Array[unchecked out Elem] < Object
3172
3192
  # a = [1, 1, 1, 2, 2, 3]
3173
3193
  # a.sample(a.size) # => [1, 1, 3, 2, 1, 2]
3174
3194
  #
3175
- # Returns no more than `a.size` elements (because no new duplicates are
3176
- # introduced):
3195
+ # Returns no more than <code>a.size</code> elements (because no new duplicates
3196
+ # are introduced):
3177
3197
  #
3178
3198
  # a.sample(50) # => [6, 4, 1, 8, 5, 9, 0, 2, 3, 7]
3179
3199
  #
@@ -3375,42 +3395,45 @@ class Array[unchecked out Elem] < Object
3375
3395
  # a[0, 2] # => [:foo, "bar"]
3376
3396
  # a[1, 2] # => ["bar", 2]
3377
3397
  #
3378
- # If `start + length` is greater than `self.length`, returns all elements from
3379
- # offset `start` to the end:
3398
+ # If <code>start + length</code> is greater than <code>self.length</code>,
3399
+ # returns all elements from offset `start` to the end:
3380
3400
  #
3381
3401
  # a = [:foo, 'bar', 2]
3382
3402
  # a[0, 4] # => [:foo, "bar", 2]
3383
3403
  # a[1, 3] # => ["bar", 2]
3384
3404
  # a[2, 2] # => [2]
3385
3405
  #
3386
- # If `start == self.size` and `length >= 0`, returns a new empty array.
3406
+ # If <code>start == self.size</code> and <code>length >= 0</code>, returns a new
3407
+ # empty array.
3387
3408
  #
3388
3409
  # If `length` is negative, returns `nil`.
3389
3410
  #
3390
- # When a single Range argument `range` is given, treats `range.min` as `start`
3391
- # above and `range.size` as `length` above:
3411
+ # When a single Range argument `range` is given, treats <code>range.min</code>
3412
+ # as `start` above and <code>range.size</code> as `length` above:
3392
3413
  #
3393
3414
  # a = [:foo, 'bar', 2]
3394
3415
  # a[0..1] # => [:foo, "bar"]
3395
3416
  # a[1..2] # => ["bar", 2]
3396
3417
  #
3397
- # Special case: If `range.start == a.size`, returns a new empty array.
3418
+ # Special case: If <code>range.start == a.size</code>, returns a new empty
3419
+ # array.
3398
3420
  #
3399
- # If `range.end` is negative, calculates the end index from the end:
3421
+ # If <code>range.end</code> is negative, calculates the end index from the end:
3400
3422
  #
3401
3423
  # a = [:foo, 'bar', 2]
3402
3424
  # a[0..-1] # => [:foo, "bar", 2]
3403
3425
  # a[0..-2] # => [:foo, "bar"]
3404
3426
  # a[0..-3] # => [:foo]
3405
3427
  #
3406
- # If `range.start` is negative, calculates the start index from the end:
3428
+ # If <code>range.start</code> is negative, calculates the start index from the
3429
+ # end:
3407
3430
  #
3408
3431
  # a = [:foo, 'bar', 2]
3409
3432
  # a[-1..2] # => [2]
3410
3433
  # a[-2..2] # => ["bar", 2]
3411
3434
  # a[-3..2] # => [:foo, "bar", 2]
3412
3435
  #
3413
- # If `range.start` is larger than the array size, returns `nil`.
3436
+ # If <code>range.start</code> is larger than the array size, returns `nil`.
3414
3437
  #
3415
3438
  # a = [:foo, 'bar', 2]
3416
3439
  # a[4..1] # => nil
@@ -3492,42 +3515,43 @@ class Array[unchecked out Elem] < Object
3492
3515
  # a.slice!(5, 1) # => nil
3493
3516
  # a.slice!(-5, 1) # => nil
3494
3517
  #
3495
- # If `start + length` exceeds the array size, removes and returns all elements
3496
- # from offset `start` to the end:
3518
+ # If <code>start + length</code> exceeds the array size, removes and returns all
3519
+ # elements from offset `start` to the end:
3497
3520
  #
3498
3521
  # a = ['a', 'b', 'c', 'd']
3499
3522
  # a.slice!(2, 50) # => ["c", "d"]
3500
3523
  # a # => ["a", "b"]
3501
3524
  #
3502
- # If `start == a.size` and `length` is non-negative, returns a new empty array.
3525
+ # If <code>start == a.size</code> and `length` is non-negative, returns a new
3526
+ # empty array.
3503
3527
  #
3504
3528
  # If `length` is negative, returns `nil`.
3505
3529
  #
3506
- # With Range argument `range` given, treats `range.min` as `start` (as above)
3507
- # and `range.size` as `length` (as above):
3530
+ # With Range argument `range` given, treats <code>range.min</code> as `start`
3531
+ # (as above) and <code>range.size</code> as `length` (as above):
3508
3532
  #
3509
3533
  # a = ['a', 'b', 'c', 'd']
3510
3534
  # a.slice!(1..2) # => ["b", "c"]
3511
3535
  # a # => ["a", "d"]
3512
3536
  #
3513
- # If `range.start == a.size`, returns a new empty array:
3537
+ # If <code>range.start == a.size</code>, returns a new empty array:
3514
3538
  #
3515
3539
  # a = ['a', 'b', 'c', 'd']
3516
3540
  # a.slice!(4..5) # => []
3517
3541
  #
3518
- # If `range.start` is larger than the array size, returns `nil`:
3542
+ # If <code>range.start</code> is larger than the array size, returns `nil`:
3519
3543
  #
3520
3544
  # a = ['a', 'b', 'c', 'd']
3521
3545
  # a.slice!(5..6) # => nil
3522
3546
  #
3523
- # If `range.start` is negative, calculates the start index by counting backwards
3524
- # from the end of `self`:
3547
+ # If <code>range.start</code> is negative, calculates the start index by
3548
+ # counting backwards from the end of `self`:
3525
3549
  #
3526
3550
  # a = ['a', 'b', 'c', 'd']
3527
3551
  # a.slice!(-2..2) # => ["c"]
3528
3552
  #
3529
- # If `range.end` is negative, calculates the end index by counting backwards
3530
- # from the end of `self`:
3553
+ # If <code>range.end</code> is negative, calculates the end index by counting
3554
+ # backwards from the end of `self`:
3531
3555
  #
3532
3556
  # a = ['a', 'b', 'c', 'd']
3533
3557
  # a.slice!(0..-2) # => ["a", "b", "c"]
@@ -3545,7 +3569,8 @@ class Array[unchecked out Elem] < Object
3545
3569
  # -->
3546
3570
  # Returns a new array containing the elements of `self`, sorted.
3547
3571
  #
3548
- # With no block given, compares elements using operator `#<=>` (see Object#<=>):
3572
+ # With no block given, compares elements using operator <code>#<=></code> (see
3573
+ # Object#<=>):
3549
3574
  #
3550
3575
  # [0, 2, 3, 1].sort # => [0, 1, 2, 3]
3551
3576
  #
@@ -3621,7 +3646,8 @@ class Array[unchecked out Elem] < Object
3621
3646
  # array.each {|element| sum += element }
3622
3647
  # sum
3623
3648
  #
3624
- # For example, `[e0, e1, e2].sum` returns `init + e0 + e1 + e2`.
3649
+ # For example, <code>[e0, e1, e2].sum</code> returns <code>init + e0 + e1 +
3650
+ # e2</code>.
3625
3651
  #
3626
3652
  # Examples:
3627
3653
  #
@@ -3632,7 +3658,7 @@ class Array[unchecked out Elem] < Object
3632
3658
  # # => [2, 3, :foo, :bar, "foo", "bar"]
3633
3659
  #
3634
3660
  # The `init` value and elements need not be numeric, but must all be
3635
- # `+`-compatible:
3661
+ # <code>+</code>-compatible:
3636
3662
  #
3637
3663
  # # Raises TypeError: Array can't be coerced into Integer.
3638
3664
  # [[:foo, :bar], ['foo', 'bar']].sum(2)
@@ -3747,8 +3773,8 @@ class Array[unchecked out Elem] < Object
3747
3773
  | [T, S] () { (Elem) -> [ T, S ] } -> Hash[T, S]
3748
3774
 
3749
3775
  # <!-- rdoc-file=array.c -->
3750
- # Returns the new string formed by calling method `#inspect` on each array
3751
- # element:
3776
+ # Returns the new string formed by calling method <code>#inspect</code> on each
3777
+ # array element:
3752
3778
  #
3753
3779
  # a = [:foo, 'bar', 2]
3754
3780
  # a.inspect # => "[:foo, \"bar\", 2]"
@@ -3778,7 +3804,7 @@ class Array[unchecked out Elem] < Object
3778
3804
  # - union(*other_arrays) -> new_array
3779
3805
  # -->
3780
3806
  # Returns a new array that is the union of the elements of `self` and all given
3781
- # arrays `other_arrays`; items are compared using `eql?`:
3807
+ # arrays `other_arrays`; items are compared using <code>eql?</code>:
3782
3808
  #
3783
3809
  # [0, 1, 2, 3].union([4, 5], [6, 7]) # => [0, 1, 2, 3, 4, 5, 6, 7]
3784
3810
  #
@@ -3805,15 +3831,15 @@ class Array[unchecked out Elem] < Object
3805
3831
  # duplicates, the first occurrence always being retained.
3806
3832
  #
3807
3833
  # With no block given, identifies and omits duplicate elements using method
3808
- # `eql?` to compare elements:
3834
+ # <code>eql?</code> to compare elements:
3809
3835
  #
3810
3836
  # a = [0, 0, 1, 1, 2, 2]
3811
3837
  # a.uniq # => [0, 1, 2]
3812
3838
  #
3813
3839
  # With a block given, calls the block for each element; identifies and omits
3814
- # "duplicate" elements using method `eql?` to compare *block return values*;
3815
- # that is, an element is a duplicate if its block return value is the same as
3816
- # that of a previous element:
3840
+ # "duplicate" elements using method <code>eql?</code> to compare *block return
3841
+ # values*; that is, an element is a duplicate if its block return value is the
3842
+ # same as that of a previous element:
3817
3843
  #
3818
3844
  # a = ['a', 'aa', 'aaa', 'b', 'bb', 'bbb']
3819
3845
  # a.uniq {|element| element.size } # => ["a", "aa", "aaa"]
@@ -3831,17 +3857,17 @@ class Array[unchecked out Elem] < Object
3831
3857
  # Removes duplicate elements from `self`, the first occurrence always being
3832
3858
  # retained; returns `self` if any elements removed, `nil` otherwise.
3833
3859
  #
3834
- # With no block given, identifies and removes elements using method `eql?` to
3835
- # compare elements:
3860
+ # With no block given, identifies and removes elements using method
3861
+ # <code>eql?</code> to compare elements:
3836
3862
  #
3837
3863
  # a = [0, 0, 1, 1, 2, 2]
3838
3864
  # a.uniq! # => [0, 1, 2]
3839
3865
  # a.uniq! # => nil
3840
3866
  #
3841
3867
  # With a block given, calls the block for each element; identifies and omits
3842
- # "duplicate" elements using method `eql?` to compare *block return values*;
3843
- # that is, an element is a duplicate if its block return value is the same as
3844
- # that of a previous element:
3868
+ # "duplicate" elements using method <code>eql?</code> to compare *block return
3869
+ # values*; that is, an element is a duplicate if its block return value is the
3870
+ # same as that of a previous element:
3845
3871
  #
3846
3872
  # a = ['a', 'aa', 'aaa', 'b', 'bb', 'bbb']
3847
3873
  # a.uniq! {|element| element.size } # => ["a", "aa", "aaa"]
@@ -3907,13 +3933,13 @@ class Array[unchecked out Elem] < Object
3907
3933
  # For each numeric specifier `index`, includes an element:
3908
3934
  #
3909
3935
  # * For each non-negative numeric specifier `index` that is in-range (less
3910
- # than `self.size`), includes the element at offset `index`:
3936
+ # than <code>self.size</code>), includes the element at offset `index`:
3911
3937
  #
3912
3938
  # a.values_at(0, 2) # => ["a", "c"]
3913
3939
  # a.values_at(0.1, 2.9) # => ["a", "c"]
3914
3940
  #
3915
3941
  # * For each negative numeric `index` that is in-range (greater than or equal
3916
- # to `- self.size`), counts backwards from the end of `self`:
3942
+ # to <code>- self.size</code>), counts backwards from the end of `self`:
3917
3943
  #
3918
3944
  # a.values_at(-1, -4) # => ["d", "a"]
3919
3945
  #
@@ -3925,37 +3951,41 @@ class Array[unchecked out Elem] < Object
3925
3951
  #
3926
3952
  # a.values_at(4, -5) # => [nil, nil]
3927
3953
  #
3928
- # For each Range specifier `range`, includes elements according to `range.begin`
3929
- # and `range.end`:
3954
+ # For each Range specifier `range`, includes elements according to
3955
+ # <code>range.begin</code> and <code>range.end</code>:
3930
3956
  #
3931
- # * If both `range.begin` and `range.end` are non-negative and in-range (less
3932
- # than `self.size`), includes elements from index `range.begin` through
3933
- # `range.end - 1` (if `range.exclude_end?`), or through `range.end`
3934
- # (otherwise):
3957
+ # * If both <code>range.begin</code> and <code>range.end</code> are
3958
+ # non-negative and in-range (less than <code>self.size</code>), includes
3959
+ # elements from index <code>range.begin</code> through <code>range.end -
3960
+ # 1</code> (if <code>range.exclude_end?</code>), or through
3961
+ # <code>range.end</code> (otherwise):
3935
3962
  #
3936
3963
  # a.values_at(1..2) # => ["b", "c"]
3937
3964
  # a.values_at(1...2) # => ["b"]
3938
3965
  #
3939
- # * If `range.begin` is negative and in-range (greater than or equal to `-
3940
- # self.size`), counts backwards from the end of `self`:
3966
+ # * If <code>range.begin</code> is negative and in-range (greater than or
3967
+ # equal to <code>- self.size</code>), counts backwards from the end of
3968
+ # `self`:
3941
3969
  #
3942
3970
  # a.values_at(-2..3) # => ["c", "d"]
3943
3971
  #
3944
- # * If `range.begin` is negative and out-of-range, raises an exception:
3972
+ # * If <code>range.begin</code> is negative and out-of-range, raises an
3973
+ # exception:
3945
3974
  #
3946
3975
  # a.values_at(-5..3) # Raises RangeError.
3947
3976
  #
3948
- # * If `range.end` is positive and out-of-range, extends the returned array
3949
- # with `nil` elements:
3977
+ # * If <code>range.end</code> is positive and out-of-range, extends the
3978
+ # returned array with `nil` elements:
3950
3979
  #
3951
3980
  # a.values_at(1..5) # => ["b", "c", "d", nil, nil]
3952
3981
  #
3953
- # * If `range.end` is negative and in-range, counts backwards from the end of
3954
- # `self`:
3982
+ # * If <code>range.end</code> is negative and in-range, counts backwards from
3983
+ # the end of `self`:
3955
3984
  #
3956
3985
  # a.values_at(1..-2) # => ["b", "c"]
3957
3986
  #
3958
- # * If `range.end` is negative and out-of-range, returns an empty array:
3987
+ # * If <code>range.end</code> is negative and out-of-range, returns an empty
3988
+ # array:
3959
3989
  #
3960
3990
  # a.values_at(1..-5) # => []
3961
3991
  #
@@ -3984,8 +4014,8 @@ class Array[unchecked out Elem] < Object
3984
4014
  #
3985
4015
  # Returned:
3986
4016
  #
3987
- # * The outer array is of size `self.size`.
3988
- # * Each sub-array is of size `other_arrays.size + 1`.
4017
+ # * The outer array is of size <code>self.size</code>.
4018
+ # * Each sub-array is of size <code>other_arrays.size + 1</code>.
3989
4019
  # * The *nth* sub-array contains (in order):
3990
4020
  #
3991
4021
  # * The *nth* element of `self`.
@@ -4058,8 +4088,8 @@ class Array[unchecked out Elem] < Object
4058
4088
  # [:c3, :b3, :a3]]
4059
4089
  #
4060
4090
  # For an **object** in **other_arrays** that is not actually an array, forms the
4061
- # "other array" as `object.to_ary`, if defined, or as `object.each.to_a`
4062
- # otherwise.
4091
+ # "other array" as <code>object.to_ary</code>, if defined, or as
4092
+ # <code>object.each.to_a</code> otherwise.
4063
4093
  #
4064
4094
  # Related: see [Methods for Converting](rdoc-ref:Array@Methods+for+Converting).
4065
4095
  #
@@ -4073,7 +4103,7 @@ class Array[unchecked out Elem] < Object
4073
4103
  # - self | other_array -> new_array
4074
4104
  # -->
4075
4105
  # Returns the union of `self` and `other_array`; duplicates are removed; order
4076
- # is preserved; items are compared using `eql?`:
4106
+ # is preserved; items are compared using <code>eql?</code>:
4077
4107
  #
4078
4108
  # [0, 1] | [2, 3] # => [0, 1, 2, 3]
4079
4109
  # [0, 1, 1] | [2, 2, 3] # => [0, 1, 2, 3]