rbs 4.0.0.dev.4 → 4.0.0

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 (281) hide show
  1. checksums.yaml +4 -4
  2. data/.github/dependabot.yml +14 -14
  3. data/.github/workflows/bundle-update.yml +60 -0
  4. data/.github/workflows/c-check.yml +18 -11
  5. data/.github/workflows/comments.yml +5 -3
  6. data/.github/workflows/dependabot.yml +2 -2
  7. data/.github/workflows/ruby.yml +27 -34
  8. data/.github/workflows/rust.yml +95 -0
  9. data/.github/workflows/typecheck.yml +2 -2
  10. data/.github/workflows/windows.yml +2 -2
  11. data/.rubocop.yml +1 -1
  12. data/CHANGELOG.md +323 -0
  13. data/README.md +1 -1
  14. data/Rakefile +43 -33
  15. data/Steepfile +1 -0
  16. data/config.yml +426 -24
  17. data/core/array.rbs +307 -227
  18. data/core/basic_object.rbs +9 -8
  19. data/core/binding.rbs +0 -2
  20. data/core/builtin.rbs +2 -2
  21. data/core/class.rbs +6 -5
  22. data/core/comparable.rbs +55 -34
  23. data/core/complex.rbs +104 -78
  24. data/core/dir.rbs +61 -49
  25. data/core/encoding.rbs +12 -15
  26. data/core/enumerable.rbs +179 -87
  27. data/core/enumerator/arithmetic_sequence.rbs +70 -0
  28. data/core/enumerator.rbs +65 -2
  29. data/core/errno.rbs +11 -2
  30. data/core/errors.rbs +58 -29
  31. data/core/exception.rbs +13 -13
  32. data/core/fiber.rbs +74 -54
  33. data/core/file.rbs +280 -177
  34. data/core/file_test.rbs +3 -3
  35. data/core/float.rbs +257 -92
  36. data/core/gc.rbs +425 -281
  37. data/core/hash.rbs +1045 -739
  38. data/core/integer.rbs +135 -137
  39. data/core/io/buffer.rbs +53 -42
  40. data/core/io/wait.rbs +13 -35
  41. data/core/io.rbs +192 -144
  42. data/core/kernel.rbs +216 -155
  43. data/core/marshal.rbs +4 -4
  44. data/core/match_data.rbs +15 -13
  45. data/core/math.rbs +107 -66
  46. data/core/method.rbs +69 -33
  47. data/core/module.rbs +244 -106
  48. data/core/nil_class.rbs +7 -6
  49. data/core/numeric.rbs +74 -63
  50. data/core/object.rbs +9 -11
  51. data/core/object_space.rbs +30 -23
  52. data/core/pathname.rbs +1322 -0
  53. data/core/proc.rbs +95 -58
  54. data/core/process.rbs +222 -202
  55. data/core/ractor.rbs +371 -515
  56. data/core/random.rbs +21 -3
  57. data/core/range.rbs +159 -57
  58. data/core/rational.rbs +60 -89
  59. data/core/rbs/unnamed/argf.rbs +60 -53
  60. data/core/rbs/unnamed/env_class.rbs +19 -14
  61. data/core/rbs/unnamed/main_class.rbs +123 -0
  62. data/core/rbs/unnamed/random.rbs +11 -118
  63. data/core/regexp.rbs +258 -214
  64. data/core/ruby.rbs +53 -0
  65. data/core/ruby_vm.rbs +38 -34
  66. data/core/rubygems/config_file.rbs +5 -5
  67. data/core/rubygems/errors.rbs +4 -71
  68. data/core/rubygems/requirement.rbs +5 -5
  69. data/core/rubygems/rubygems.rbs +16 -82
  70. data/core/rubygems/version.rbs +2 -3
  71. data/core/set.rbs +490 -360
  72. data/core/signal.rbs +26 -16
  73. data/core/string.rbs +3234 -1285
  74. data/core/struct.rbs +27 -26
  75. data/core/symbol.rbs +41 -34
  76. data/core/thread.rbs +135 -67
  77. data/core/time.rbs +81 -50
  78. data/core/trace_point.rbs +41 -35
  79. data/core/true_class.rbs +2 -2
  80. data/core/unbound_method.rbs +24 -16
  81. data/core/warning.rbs +7 -7
  82. data/docs/aliases.md +79 -0
  83. data/docs/collection.md +3 -3
  84. data/docs/config.md +171 -0
  85. data/docs/encoding.md +56 -0
  86. data/docs/gem.md +0 -1
  87. data/docs/inline.md +576 -0
  88. data/docs/sigs.md +3 -3
  89. data/docs/syntax.md +46 -16
  90. data/docs/type_fingerprint.md +21 -0
  91. data/exe/rbs +1 -1
  92. data/ext/rbs_extension/ast_translation.c +544 -116
  93. data/ext/rbs_extension/ast_translation.h +3 -0
  94. data/ext/rbs_extension/class_constants.c +16 -2
  95. data/ext/rbs_extension/class_constants.h +8 -0
  96. data/ext/rbs_extension/extconf.rb +5 -1
  97. data/ext/rbs_extension/legacy_location.c +33 -56
  98. data/ext/rbs_extension/legacy_location.h +37 -0
  99. data/ext/rbs_extension/main.c +44 -35
  100. data/include/rbs/ast.h +448 -173
  101. data/include/rbs/defines.h +27 -0
  102. data/include/rbs/lexer.h +30 -11
  103. data/include/rbs/location.h +25 -44
  104. data/include/rbs/parser.h +6 -6
  105. data/include/rbs/string.h +0 -2
  106. data/include/rbs/util/rbs_allocator.h +34 -13
  107. data/include/rbs/util/rbs_assert.h +12 -1
  108. data/include/rbs/util/rbs_constant_pool.h +0 -3
  109. data/include/rbs/util/rbs_encoding.h +2 -0
  110. data/include/rbs/util/rbs_unescape.h +2 -1
  111. data/include/rbs.h +8 -0
  112. data/lib/rbs/ast/annotation.rb +1 -1
  113. data/lib/rbs/ast/comment.rb +1 -1
  114. data/lib/rbs/ast/declarations.rb +10 -10
  115. data/lib/rbs/ast/members.rb +14 -14
  116. data/lib/rbs/ast/ruby/annotations.rb +293 -3
  117. data/lib/rbs/ast/ruby/comment_block.rb +24 -0
  118. data/lib/rbs/ast/ruby/declarations.rb +198 -3
  119. data/lib/rbs/ast/ruby/helpers/constant_helper.rb +4 -0
  120. data/lib/rbs/ast/ruby/members.rb +532 -22
  121. data/lib/rbs/ast/type_param.rb +24 -4
  122. data/lib/rbs/buffer.rb +20 -15
  123. data/lib/rbs/cli/diff.rb +16 -15
  124. data/lib/rbs/cli/validate.rb +38 -106
  125. data/lib/rbs/cli.rb +52 -19
  126. data/lib/rbs/collection/config/lockfile_generator.rb +14 -2
  127. data/lib/rbs/collection/sources/git.rb +1 -0
  128. data/lib/rbs/definition.rb +1 -1
  129. data/lib/rbs/definition_builder/ancestor_builder.rb +62 -9
  130. data/lib/rbs/definition_builder/method_builder.rb +20 -0
  131. data/lib/rbs/definition_builder.rb +147 -25
  132. data/lib/rbs/diff.rb +7 -1
  133. data/lib/rbs/environment.rb +227 -74
  134. data/lib/rbs/environment_loader.rb +0 -6
  135. data/lib/rbs/errors.rb +27 -18
  136. data/lib/rbs/inline_parser.rb +342 -6
  137. data/lib/rbs/location_aux.rb +1 -1
  138. data/lib/rbs/locator.rb +5 -1
  139. data/lib/rbs/method_type.rb +5 -3
  140. data/lib/rbs/parser_aux.rb +20 -7
  141. data/lib/rbs/prototype/helpers.rb +57 -0
  142. data/lib/rbs/prototype/rb.rb +3 -28
  143. data/lib/rbs/prototype/rbi.rb +3 -20
  144. data/lib/rbs/prototype/runtime.rb +8 -0
  145. data/lib/rbs/resolver/constant_resolver.rb +2 -2
  146. data/lib/rbs/resolver/type_name_resolver.rb +116 -38
  147. data/lib/rbs/subtractor.rb +3 -1
  148. data/lib/rbs/test/type_check.rb +19 -2
  149. data/lib/rbs/type_name.rb +1 -1
  150. data/lib/rbs/types.rb +88 -78
  151. data/lib/rbs/unit_test/type_assertions.rb +35 -8
  152. data/lib/rbs/validator.rb +2 -2
  153. data/lib/rbs/version.rb +1 -1
  154. data/lib/rbs.rb +1 -2
  155. data/lib/rdoc/discover.rb +1 -1
  156. data/lib/rdoc_plugin/parser.rb +1 -1
  157. data/rbs.gemspec +4 -3
  158. data/rust/.gitignore +1 -0
  159. data/rust/Cargo.lock +378 -0
  160. data/rust/Cargo.toml +7 -0
  161. data/rust/ruby-rbs/Cargo.toml +22 -0
  162. data/rust/ruby-rbs/build.rs +764 -0
  163. data/rust/ruby-rbs/examples/locations.rs +60 -0
  164. data/rust/ruby-rbs/src/lib.rs +1 -0
  165. data/rust/ruby-rbs/src/node/mod.rs +742 -0
  166. data/rust/ruby-rbs/tests/sanity.rs +47 -0
  167. data/rust/ruby-rbs/vendor/rbs/config.yml +1 -0
  168. data/rust/ruby-rbs-sys/Cargo.toml +23 -0
  169. data/rust/ruby-rbs-sys/build.rs +204 -0
  170. data/rust/ruby-rbs-sys/src/lib.rs +50 -0
  171. data/rust/ruby-rbs-sys/vendor/rbs/include +1 -0
  172. data/rust/ruby-rbs-sys/vendor/rbs/src +1 -0
  173. data/rust/ruby-rbs-sys/wrapper.h +1 -0
  174. data/schema/typeParam.json +17 -1
  175. data/sig/ast/ruby/annotations.rbs +315 -4
  176. data/sig/ast/ruby/comment_block.rbs +8 -0
  177. data/sig/ast/ruby/declarations.rbs +102 -4
  178. data/sig/ast/ruby/members.rbs +108 -2
  179. data/sig/cli/diff.rbs +5 -11
  180. data/sig/cli/validate.rbs +12 -8
  181. data/sig/cli.rbs +18 -18
  182. data/sig/definition.rbs +6 -1
  183. data/sig/definition_builder.rbs +2 -0
  184. data/sig/environment.rbs +70 -12
  185. data/sig/errors.rbs +13 -14
  186. data/sig/inline_parser.rbs +39 -2
  187. data/sig/locator.rbs +0 -2
  188. data/sig/manifest.yaml +0 -1
  189. data/sig/method_builder.rbs +3 -1
  190. data/sig/parser.rbs +31 -13
  191. data/sig/prototype/helpers.rbs +2 -0
  192. data/sig/resolver/type_name_resolver.rbs +35 -7
  193. data/sig/source.rbs +3 -3
  194. data/sig/type_param.rbs +13 -8
  195. data/sig/types.rbs +6 -7
  196. data/sig/unit_test/spy.rbs +0 -8
  197. data/sig/unit_test/type_assertions.rbs +11 -0
  198. data/src/ast.c +410 -153
  199. data/src/lexer.c +1392 -1313
  200. data/src/lexer.re +3 -0
  201. data/src/lexstate.c +58 -37
  202. data/src/location.c +8 -48
  203. data/src/parser.c +977 -516
  204. data/src/string.c +0 -48
  205. data/src/util/rbs_allocator.c +89 -71
  206. data/src/util/rbs_assert.c +1 -1
  207. data/src/util/rbs_buffer.c +2 -2
  208. data/src/util/rbs_constant_pool.c +10 -14
  209. data/src/util/rbs_encoding.c +4 -8
  210. data/src/util/rbs_unescape.c +56 -20
  211. data/stdlib/bigdecimal/0/big_decimal.rbs +116 -98
  212. data/stdlib/bigdecimal-math/0/big_math.rbs +169 -8
  213. data/stdlib/cgi/0/core.rbs +9 -393
  214. data/stdlib/cgi/0/manifest.yaml +1 -0
  215. data/stdlib/cgi-escape/0/escape.rbs +171 -0
  216. data/stdlib/coverage/0/coverage.rbs +7 -4
  217. data/stdlib/date/0/date.rbs +92 -79
  218. data/stdlib/date/0/date_time.rbs +25 -24
  219. data/stdlib/delegate/0/delegator.rbs +10 -7
  220. data/stdlib/did_you_mean/0/did_you_mean.rbs +17 -16
  221. data/stdlib/digest/0/digest.rbs +110 -0
  222. data/stdlib/erb/0/erb.rbs +748 -347
  223. data/stdlib/etc/0/etc.rbs +55 -50
  224. data/stdlib/fileutils/0/fileutils.rbs +158 -139
  225. data/stdlib/forwardable/0/forwardable.rbs +13 -10
  226. data/stdlib/io-console/0/io-console.rbs +2 -2
  227. data/stdlib/json/0/json.rbs +217 -136
  228. data/stdlib/monitor/0/monitor.rbs +3 -3
  229. data/stdlib/net-http/0/net-http.rbs +162 -134
  230. data/stdlib/objspace/0/objspace.rbs +17 -34
  231. data/stdlib/open-uri/0/open-uri.rbs +48 -8
  232. data/stdlib/open3/0/open3.rbs +469 -10
  233. data/stdlib/openssl/0/openssl.rbs +475 -357
  234. data/stdlib/optparse/0/optparse.rbs +26 -17
  235. data/stdlib/pathname/0/pathname.rbs +11 -1381
  236. data/stdlib/pp/0/pp.rbs +9 -8
  237. data/stdlib/prettyprint/0/prettyprint.rbs +7 -7
  238. data/stdlib/pstore/0/pstore.rbs +35 -30
  239. data/stdlib/psych/0/psych.rbs +65 -12
  240. data/stdlib/psych/0/store.rbs +2 -4
  241. data/stdlib/pty/0/pty.rbs +9 -6
  242. data/stdlib/random-formatter/0/random-formatter.rbs +277 -0
  243. data/stdlib/rdoc/0/code_object.rbs +2 -1
  244. data/stdlib/rdoc/0/parser.rbs +1 -1
  245. data/stdlib/rdoc/0/rdoc.rbs +1 -1
  246. data/stdlib/rdoc/0/store.rbs +1 -1
  247. data/stdlib/resolv/0/resolv.rbs +25 -68
  248. data/stdlib/ripper/0/ripper.rbs +22 -19
  249. data/stdlib/securerandom/0/manifest.yaml +2 -0
  250. data/stdlib/securerandom/0/securerandom.rbs +7 -20
  251. data/stdlib/shellwords/0/shellwords.rbs +2 -2
  252. data/stdlib/singleton/0/singleton.rbs +3 -0
  253. data/stdlib/socket/0/addrinfo.rbs +7 -7
  254. data/stdlib/socket/0/basic_socket.rbs +3 -3
  255. data/stdlib/socket/0/ip_socket.rbs +10 -8
  256. data/stdlib/socket/0/socket.rbs +23 -10
  257. data/stdlib/socket/0/tcp_server.rbs +1 -1
  258. data/stdlib/socket/0/tcp_socket.rbs +11 -3
  259. data/stdlib/socket/0/udp_socket.rbs +1 -1
  260. data/stdlib/socket/0/unix_server.rbs +1 -1
  261. data/stdlib/stringio/0/stringio.rbs +1177 -85
  262. data/stdlib/strscan/0/string_scanner.rbs +27 -25
  263. data/stdlib/tempfile/0/tempfile.rbs +25 -21
  264. data/stdlib/time/0/time.rbs +8 -6
  265. data/stdlib/timeout/0/timeout.rbs +63 -7
  266. data/stdlib/tsort/0/cyclic.rbs +3 -0
  267. data/stdlib/tsort/0/tsort.rbs +7 -6
  268. data/stdlib/uri/0/common.rbs +42 -20
  269. data/stdlib/uri/0/file.rbs +3 -3
  270. data/stdlib/uri/0/generic.rbs +26 -18
  271. data/stdlib/uri/0/http.rbs +2 -2
  272. data/stdlib/uri/0/ldap.rbs +2 -2
  273. data/stdlib/uri/0/mailto.rbs +3 -3
  274. data/stdlib/uri/0/rfc2396_parser.rbs +12 -12
  275. data/stdlib/zlib/0/deflate.rbs +4 -3
  276. data/stdlib/zlib/0/gzip_reader.rbs +6 -6
  277. data/stdlib/zlib/0/gzip_writer.rbs +14 -12
  278. data/stdlib/zlib/0/inflate.rbs +1 -1
  279. data/stdlib/zlib/0/need_dict.rbs +1 -1
  280. data/stdlib/zlib/0/zstream.rbs +1 -0
  281. metadata +50 -6
data/core/array.rbs CHANGED
@@ -151,8 +151,8 @@
151
151
  #
152
152
  # ## Example Usage
153
153
  #
154
- # In addition to the methods it mixes in through the Enumerable module, the
155
- # `Array` class has proprietary methods for accessing, searching and otherwise
154
+ # In addition to the methods it mixes in through the Enumerable module, class
155
+ # Array has proprietary methods for accessing, searching and otherwise
156
156
  # manipulating arrays.
157
157
  #
158
158
  # Some of the more common ones are illustrated below.
@@ -200,9 +200,9 @@
200
200
  #
201
201
  # arr.drop(3) #=> [4, 5, 6]
202
202
  #
203
- # ## Obtaining Information about an `Array`
203
+ # ## Obtaining Information about an Array
204
204
  #
205
- # Arrays keep track of their own length at all times. To query an array about
205
+ # An array keeps track of its own length at all times. To query an array about
206
206
  # the number of elements it contains, use #length, #count or #size.
207
207
  #
208
208
  # browsers = ['Chrome', 'Firefox', 'Safari', 'Opera', 'IE']
@@ -217,7 +217,7 @@
217
217
  #
218
218
  # browsers.include?('Konqueror') #=> false
219
219
  #
220
- # ## Adding Items to Arrays
220
+ # ## Adding Items to an Array
221
221
  #
222
222
  # Items can be added to the end of an array by using either #push or #<<
223
223
  #
@@ -238,7 +238,7 @@
238
238
  # arr.insert(3, 'orange', 'pear', 'grapefruit')
239
239
  # #=> [0, 1, 2, "orange", "pear", "grapefruit", "apple", 3, 4, 5, 6]
240
240
  #
241
- # ## Removing Items from an `Array`
241
+ # ## Removing Items from an Array
242
242
  #
243
243
  # The method #pop removes the last element in an array and returns it:
244
244
  #
@@ -277,12 +277,12 @@
277
277
  # arr = [2, 5, 6, 556, 6, 6, 8, 9, 0, 123, 556]
278
278
  # arr.uniq #=> [2, 5, 6, 556, 8, 9, 0, 123]
279
279
  #
280
- # ## Iterating over Arrays
280
+ # ## Iterating over an Array
281
281
  #
282
- # Like all classes that include the Enumerable module, `Array` has an each
282
+ # Like all classes that include the Enumerable module, class Array has an each
283
283
  # method, which defines what elements should be iterated over and how. In case
284
- # of Array's #each, all elements in the `Array` instance are yielded to the
285
- # supplied block in sequence.
284
+ # of Array#each, all elements in `self` are yielded to the supplied block in
285
+ # sequence.
286
286
  #
287
287
  # Note that this operation leaves the array unchanged.
288
288
  #
@@ -307,7 +307,7 @@
307
307
  # arr.map! {|a| a**2} #=> [1, 4, 9, 16, 25]
308
308
  # arr #=> [1, 4, 9, 16, 25]
309
309
  #
310
- # ## Selecting Items from an `Array`
310
+ # ## Selecting Items from an Array
311
311
  #
312
312
  # Elements can be selected from an array according to criteria defined in a
313
313
  # block. The selection can happen in a destructive or a non-destructive manner.
@@ -340,13 +340,13 @@
340
340
  #
341
341
  # ## What's Here
342
342
  #
343
- # First, what's elsewhere. Class `Array`:
343
+ # First, what's elsewhere. Class Array:
344
344
  #
345
345
  # * Inherits from [class Object](rdoc-ref:Object@What-27s+Here).
346
346
  # * Includes [module Enumerable](rdoc-ref:Enumerable@What-27s+Here), which
347
347
  # provides dozens of additional methods.
348
348
  #
349
- # Here, class `Array` provides methods that are useful for:
349
+ # Here, class Array provides methods that are useful for:
350
350
  #
351
351
  # * [Creating an Array](rdoc-ref:Array@Methods+for+Creating+an+Array)
352
352
  # * [Querying](rdoc-ref:Array@Methods+for+Querying)
@@ -359,7 +359,7 @@
359
359
  # * [Converting](rdoc-ref:Array@Methods+for+Converting)
360
360
  # * [And more....](rdoc-ref:Array@Other+Methods)
361
361
  #
362
- # ### Methods for Creating an `Array`
362
+ # ### Methods for Creating an Array
363
363
  #
364
364
  # * ::[]: Returns a new array populated with given objects.
365
365
  # * ::new: Returns a new array.
@@ -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.
@@ -524,7 +524,7 @@
524
524
  # return-value.
525
525
  # * #flatten: Returns an array that is a recursive flattening of `self`.
526
526
  # * #inspect (aliased as #to_s): Returns a new String containing the elements.
527
- # * #join: Returns a newsString containing the elements joined by the field
527
+ # * #join: Returns a new String containing the elements joined by the field
528
528
  # separator.
529
529
  # * #to_a: Returns `self` or a new array containing all elements.
530
530
  # * #to_ary: Returns `self`.
@@ -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
  #
@@ -840,50 +842,52 @@ class Array[unchecked out Elem] < Object
840
842
  #
841
843
  # If `index` is out of range, returns `nil`.
842
844
  #
843
- # When two Integer arguments `start` and `length` are given, returns a new
844
- # `Array` of size `length` containing successive elements beginning at offset
845
- # `start`:
845
+ # When two Integer arguments `start` and `length` are given, returns a new array
846
+ # of size `length` containing successive elements beginning at offset `start`:
846
847
  #
847
848
  # a = [:foo, 'bar', 2]
848
849
  # a[0, 2] # => [:foo, "bar"]
849
850
  # a[1, 2] # => ["bar", 2]
850
851
  #
851
- # If `start + length` is greater than `self.length`, returns all elements from
852
- # 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:
853
854
  #
854
855
  # a = [:foo, 'bar', 2]
855
856
  # a[0, 4] # => [:foo, "bar", 2]
856
857
  # a[1, 3] # => ["bar", 2]
857
858
  # a[2, 2] # => [2]
858
859
  #
859
- # 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.
860
862
  #
861
863
  # If `length` is negative, returns `nil`.
862
864
  #
863
- # When a single Range argument `range` is given, treats `range.min` as `start`
864
- # 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:
865
867
  #
866
868
  # a = [:foo, 'bar', 2]
867
869
  # a[0..1] # => [:foo, "bar"]
868
870
  # a[1..2] # => ["bar", 2]
869
871
  #
870
- # 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.
871
874
  #
872
- # 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:
873
876
  #
874
877
  # a = [:foo, 'bar', 2]
875
878
  # a[0..-1] # => [:foo, "bar", 2]
876
879
  # a[0..-2] # => [:foo, "bar"]
877
880
  # a[0..-3] # => [:foo]
878
881
  #
879
- # 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:
880
884
  #
881
885
  # a = [:foo, 'bar', 2]
882
886
  # a[-1..2] # => [2]
883
887
  # a[-2..2] # => ["bar", 2]
884
888
  # a[-3..2] # => [:foo, "bar", 2]
885
889
  #
886
- # 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`.
887
891
  #
888
892
  # a = [:foo, 'bar', 2]
889
893
  # a[4..1] # => nil
@@ -891,7 +895,7 @@ class Array[unchecked out Elem] < Object
891
895
  # a[4..-1] # => nil
892
896
  #
893
897
  # When a single Enumerator::ArithmeticSequence argument `aseq` is given, returns
894
- # an `Array` of elements corresponding to the indexes produced by the sequence.
898
+ # an array of elements corresponding to the indexes produced by the sequence.
895
899
  #
896
900
  # a = ['--', 'data1', '--', 'data2', '--', 'data3']
897
901
  # a[(1..).step(2)] # => ["data1", "data2", "data3"]
@@ -963,7 +967,7 @@ class Array[unchecked out Elem] < Object
963
967
  # a[0] = 'foo' # => "foo"
964
968
  # a # => ["foo", "bar", 2]
965
969
  #
966
- # If `index` is greater than `self.length`, extends the array:
970
+ # If `index` is greater than <code>self.length</code>, extends the array:
967
971
  #
968
972
  # a = [:foo, 'bar', 2]
969
973
  # a[7] = 'foo' # => "foo"
@@ -976,8 +980,8 @@ class Array[unchecked out Elem] < Object
976
980
  # a # => [:foo, "bar", "two"]
977
981
  #
978
982
  # When Integer arguments `start` and `length` are given and `object` is not an
979
- # `Array`, removes `length - 1` elements beginning at offset `start`, and
980
- # assigns `object` at offset `start`:
983
+ # array, removes <code>length - 1</code> elements beginning at offset `start`,
984
+ # and assigns `object` at offset `start`:
981
985
  #
982
986
  # a = [:foo, 'bar', 2]
983
987
  # a[0, 2] = 'foo' # => "foo"
@@ -989,8 +993,8 @@ class Array[unchecked out Elem] < Object
989
993
  # a[-2, 2] = 'foo' # => "foo"
990
994
  # a # => [:foo, "foo"]
991
995
  #
992
- # If `start` is non-negative and outside the array (` >= self.size`), extends
993
- # 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
994
998
  # `length`:
995
999
  #
996
1000
  # a = [:foo, 'bar', 2]
@@ -1010,36 +1014,39 @@ class Array[unchecked out Elem] < Object
1010
1014
  # a[1, 5] = 'foo' # => "foo"
1011
1015
  # a # => [:foo, "foo"]
1012
1016
  #
1013
- # When Range argument `range` is given and `object` is not an `Array`, removes
1014
- # `length - 1` elements beginning at offset `start`, and assigns `object` at
1015
- # offset `start`:
1017
+ # When Range argument `range` is given and `object` is not an array, removes
1018
+ # <code>length - 1</code> elements beginning at offset `start`, and assigns
1019
+ # `object` at offset `start`:
1016
1020
  #
1017
1021
  # a = [:foo, 'bar', 2]
1018
1022
  # a[0..1] = 'foo' # => "foo"
1019
1023
  # a # => ["foo", 2]
1020
1024
  #
1021
- # 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:
1022
1027
  #
1023
1028
  # a = [:foo, 'bar', 2]
1024
1029
  # a[-2..2] = 'foo' # => "foo"
1025
1030
  # a # => [:foo, "foo"]
1026
1031
  #
1027
- # If the array length is less than `range.begin`, extends the array with `nil`,
1028
- # 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`:
1029
1035
  #
1030
1036
  # a = [:foo, 'bar', 2]
1031
1037
  # a[6..50] = 'foo' # => "foo"
1032
1038
  # a # => [:foo, "bar", 2, nil, nil, nil, "foo"]
1033
1039
  #
1034
- # If `range.end` is zero, shifts elements at and following offset `start` and
1035
- # 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`:
1036
1042
  #
1037
1043
  # a = [:foo, 'bar', 2]
1038
1044
  # a[1..0] = 'foo' # => "foo"
1039
1045
  # a # => [:foo, "foo", "bar", 2]
1040
1046
  #
1041
- # If `range.end` is negative, assigns `object` at offset `start`, retains
1042
- # `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:
1043
1050
  #
1044
1051
  # a = [:foo, 'bar', 2]
1045
1052
  # a[1..-1] = 'foo' # => "foo"
@@ -1052,8 +1059,8 @@ class Array[unchecked out Elem] < Object
1052
1059
  # a # => [:foo, "foo", "bar", 2]
1053
1060
  # a = [:foo, 'bar', 2]
1054
1061
  #
1055
- # If `range.end` is too large for the existing array, replaces array elements,
1056
- # 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:
1057
1064
  #
1058
1065
  # a = [:foo, 'bar', 2]
1059
1066
  # a[1..5] = 'foo' # => "foo"
@@ -1084,8 +1091,8 @@ class Array[unchecked out Elem] < Object
1084
1091
  # [[], {}, '', 0, 0.0, nil].all? # => false # nil is not truthy.
1085
1092
  # [[], {}, '', 0, 0.0, false].all? # => false # false is not truthy.
1086
1093
  #
1087
- # With argument `object` given, returns whether `object === ele` for every
1088
- # element `ele` in `self`:
1094
+ # With argument `object` given, returns whether <code>object === ele</code> for
1095
+ # every element `ele` in `self`:
1089
1096
  #
1090
1097
  # [0, 0, 0].all?(0) # => true
1091
1098
  # [0, 1, 2].all?(1) # => false
@@ -1126,8 +1133,8 @@ class Array[unchecked out Elem] < Object
1126
1133
  # [nil, false, ''].any? # => true # String object is truthy.
1127
1134
  # [nil, false].any? # => false # Nil and false are not truthy.
1128
1135
  #
1129
- # With argument `object` given, returns whether `object === ele` for any element
1130
- # `ele` in `self`:
1136
+ # With argument `object` given, returns whether <code>object === ele</code> for
1137
+ # any element `ele` in `self`:
1131
1138
  #
1132
1139
  # [nil, false, 0].any?(0) # => true
1133
1140
  # [nil, false, 1].any?(0) # => false
@@ -1170,7 +1177,7 @@ class Array[unchecked out Elem] < Object
1170
1177
  # - assoc(object) -> found_array or nil
1171
1178
  # -->
1172
1179
  # Returns the first element `ele` in `self` such that `ele` is an array and
1173
- # `ele[0] == object`:
1180
+ # <code>ele[0] == object</code>:
1174
1181
  #
1175
1182
  # a = [{foo: 0}, [2, 4], [4, 5, 6], [4, 5]]
1176
1183
  # a.assoc(4) # => [4, 5, 6]
@@ -1214,7 +1221,7 @@ class Array[unchecked out Elem] < Object
1214
1221
  # Returns the element from `self` found by a binary search, or `nil` if the
1215
1222
  # search found no suitable element.
1216
1223
  #
1217
- # See [Binary Searching](rdoc-ref:bsearch.rdoc).
1224
+ # See [Binary Searching](rdoc-ref:language/bsearch.rdoc).
1218
1225
  #
1219
1226
  # Related: see [Methods for Fetching](rdoc-ref:Array@Methods+for+Fetching).
1220
1227
  #
@@ -1230,7 +1237,7 @@ class Array[unchecked out Elem] < Object
1230
1237
  # Returns the integer index of the element from `self` found by a binary search,
1231
1238
  # or `nil` if the search found no suitable element.
1232
1239
  #
1233
- # See [Binary Searching](rdoc-ref:bsearch.rdoc).
1240
+ # See [Binary Searching](rdoc-ref:language/bsearch.rdoc).
1234
1241
  #
1235
1242
  # Related: see [Methods for Fetching](rdoc-ref:Array@Methods+for+Fetching).
1236
1243
  #
@@ -1274,9 +1281,9 @@ class Array[unchecked out Elem] < Object
1274
1281
 
1275
1282
  # <!--
1276
1283
  # rdoc-file=array.c
1277
- # - collect! {|element| ... } -> new_array
1284
+ # - collect! {|element| ... } -> self
1278
1285
  # - collect! -> new_enumerator
1279
- # - map! {|element| ... } -> new_array
1286
+ # - map! {|element| ... } -> self
1280
1287
  # - map! -> new_enumerator
1281
1288
  # -->
1282
1289
  # With a block given, calls the block with each element of `self` and replaces
@@ -1300,8 +1307,8 @@ class Array[unchecked out Elem] < Object
1300
1307
  # -->
1301
1308
  # When a block and a positive [integer-convertible
1302
1309
  # object](rdoc-ref:implicit_conversion.rdoc@Integer-Convertible+Objects)
1303
- # argument `count` (`0 < count <= self.size`) are given, calls the block with
1304
- # 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`:
1305
1312
  #
1306
1313
  # a = %w[a b c] # => ["a", "b", "c"]
1307
1314
  # a.combination(2) {|combination| p combination } # => ["a", "b", "c"]
@@ -1324,8 +1331,8 @@ class Array[unchecked out Elem] < Object
1324
1331
  # []
1325
1332
  # []
1326
1333
  #
1327
- # When `count` is negative or larger than `self.size` and `self` is non-empty,
1328
- # 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:
1329
1336
  #
1330
1337
  # a.combination(-1) {|combination| fail 'Cannot happen' } # => ["a", "b", "c"]
1331
1338
  # a.combination(4) {|combination| fail 'Cannot happen' } # => ["a", "b", "c"]
@@ -1396,7 +1403,8 @@ class Array[unchecked out Elem] < Object
1396
1403
  #
1397
1404
  # [0, :one, 'two', 3, 3.0].count # => 5
1398
1405
  #
1399
- # 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`:
1400
1408
  #
1401
1409
  # [0, :one, 'two', 3, 3.0].count(3) # => 2
1402
1410
  #
@@ -1406,7 +1414,7 @@ class Array[unchecked out Elem] < Object
1406
1414
  # [0, 1, 2, 3].count {|element| element > 1 } # => 2
1407
1415
  #
1408
1416
  # With argument `object` and a block given, issues a warning, ignores the block,
1409
- # and returns the count of elements `==` to `object`.
1417
+ # and returns the count of elements <code>==</code> to `object`.
1410
1418
  #
1411
1419
  # Related: see [Methods for Querying](rdoc-ref:Array@Methods+for+Querying).
1412
1420
  #
@@ -1463,8 +1471,8 @@ class Array[unchecked out Elem] < Object
1463
1471
  # -->
1464
1472
  # Removes zero or more elements from `self`.
1465
1473
  #
1466
- # With no block given, removes from `self` each element `ele` such that `ele ==
1467
- # 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:
1468
1476
  #
1469
1477
  # a = [0, 1, 2, 2.0]
1470
1478
  # a.delete(2) # => 2.0
@@ -1474,8 +1482,8 @@ class Array[unchecked out Elem] < Object
1474
1482
  #
1475
1483
  # a.delete(2) # => nil
1476
1484
  #
1477
- # With a block given, removes from `self` each element `ele` such that `ele ==
1478
- # object`.
1485
+ # With a block given, removes from `self` each element `ele` such that <code>ele
1486
+ # == object</code>.
1479
1487
  #
1480
1488
  # If any such elements are found, ignores the block and returns the last removed
1481
1489
  # element:
@@ -1547,8 +1555,8 @@ class Array[unchecked out Elem] < Object
1547
1555
  # - difference(*other_arrays = []) -> new_array
1548
1556
  # -->
1549
1557
  # Returns a new array containing only those elements from `self` that are not
1550
- # found in any of the given `other_arrays`; items are compared using `eql?`;
1551
- # 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:
1552
1560
  #
1553
1561
  # [0, 1, 1, 2, 1, 1, 3, 1, 1].difference([1]) # => [0, 2, 3]
1554
1562
  # [0, 1, 2, 3].difference([3, 0], [1, 3]) # => [2]
@@ -1564,7 +1572,7 @@ class Array[unchecked out Elem] < Object
1564
1572
 
1565
1573
  # <!--
1566
1574
  # rdoc-file=array.c
1567
- # - array.dig(index, *identifiers) -> object
1575
+ # - dig(index, *identifiers) -> object
1568
1576
  # -->
1569
1577
  # Finds and returns the object in nested object specified by `index` and
1570
1578
  # `identifiers`; the nested objects may be instances of various classes. See
@@ -1693,7 +1701,7 @@ class Array[unchecked out Elem] < Object
1693
1701
 
1694
1702
  # <!--
1695
1703
  # rdoc-file=array.c
1696
- # - array.empty? -> true or false
1704
+ # - empty? -> true or false
1697
1705
  # -->
1698
1706
  # Returns `true` if the count of elements in `self` is zero, `false` otherwise.
1699
1707
  #
@@ -1706,7 +1714,7 @@ class Array[unchecked out Elem] < Object
1706
1714
  # - eql?(other_array) -> true or false
1707
1715
  # -->
1708
1716
  # Returns `true` if `self` and `other_array` are the same size, and if, for each
1709
- # index `i` in `self`, `self[i].eql?(other_array[i])`:
1717
+ # index `i` in `self`, <code>self[i].eql?(other_array[i])</code>:
1710
1718
  #
1711
1719
  # a0 = [:foo, 'bar', 2]
1712
1720
  # a1 = [:foo, 'bar', 2]
@@ -1715,7 +1723,7 @@ class Array[unchecked out Elem] < Object
1715
1723
  # Otherwise, returns `false`.
1716
1724
  #
1717
1725
  # This method is different from method Array#==, which compares using method
1718
- # `Object#==`.
1726
+ # <code>Object#==</code>.
1719
1727
  #
1720
1728
  # Related: see [Methods for Querying](rdoc-ref:Array@Methods+for+Querying).
1721
1729
  #
@@ -1804,10 +1812,10 @@ class Array[unchecked out Elem] < Object
1804
1812
 
1805
1813
  # <!--
1806
1814
  # rdoc-file=array.c
1807
- # - fill(object, start = nil, count = nil) -> new_array
1808
- # - fill(object, range) -> new_array
1809
- # - fill(start = nil, count = nil) {|element| ... } -> new_array
1810
- # - fill(range) {|element| ... } -> new_array
1815
+ # - fill(object, start = nil, count = nil) -> self
1816
+ # - fill(object, range) -> self
1817
+ # - fill(start = nil, count = nil) {|element| ... } -> self
1818
+ # - fill(range) {|element| ... } -> self
1811
1819
  # -->
1812
1820
  # Replaces selected elements in `self`; may add elements to `self`; always
1813
1821
  # returns `self` (never a new array).
@@ -2020,6 +2028,30 @@ class Array[unchecked out Elem] < Object
2020
2028
  def filter!: () { (Elem item) -> boolish } -> self?
2021
2029
  | () -> ::Enumerator[Elem, self?]
2022
2030
 
2031
+ # <!--
2032
+ # rdoc-file=array.c
2033
+ # - find(if_none_proc = nil) {|element| ... } -> object or nil
2034
+ # - find(if_none_proc = nil) -> enumerator
2035
+ # -->
2036
+ # Returns the first element for which the block returns a truthy value.
2037
+ #
2038
+ # With a block given, calls the block with successive elements of the array;
2039
+ # returns the first element for which the block returns a truthy value:
2040
+ #
2041
+ # [1, 3, 5].find {|element| element > 2} # => 3
2042
+ #
2043
+ # If no such element is found, calls `if_none_proc` and returns its return
2044
+ # value.
2045
+ #
2046
+ # [1, 3, 5].find(proc {-1}) {|element| element > 12} # => -1
2047
+ #
2048
+ # With no block given, returns an Enumerator.
2049
+ #
2050
+ def find: () { (Elem) -> boolish } -> Elem?
2051
+ | () -> ::Enumerator[Elem, Elem?]
2052
+ | [T] (Enumerable::_NotFound[T] ifnone) { (Elem) -> boolish } -> (Elem | T)
2053
+ | [T] (Enumerable::_NotFound[T] ifnone) -> ::Enumerator[Elem, Elem | T]
2054
+
2023
2055
  # <!--
2024
2056
  # rdoc-file=array.c
2025
2057
  # - find_index(object) -> integer or nil
@@ -2032,7 +2064,7 @@ class Array[unchecked out Elem] < Object
2032
2064
  # Returns the zero-based integer index of a specified element, or `nil`.
2033
2065
  #
2034
2066
  # With only argument `object` given, returns the index of the first element
2035
- # `element` for which `object == element`:
2067
+ # `element` for which <code>object == element</code>:
2036
2068
  #
2037
2069
  # a = [:foo, 'bar', 2, 'bar']
2038
2070
  # a.index('bar') # => 1
@@ -2174,7 +2206,8 @@ class Array[unchecked out Elem] < Object
2174
2206
  # rdoc-file=array.c
2175
2207
  # - include?(object) -> true or false
2176
2208
  # -->
2177
- # Returns whether for some element `element` in `self`, `object == element`:
2209
+ # Returns whether for some element `element` in `self`, <code>object ==
2210
+ # element</code>:
2178
2211
  #
2179
2212
  # [0, 1, 2].include?(2) # => true
2180
2213
  # [0, 1, 2].include?(2.0) # => true
@@ -2182,13 +2215,13 @@ class Array[unchecked out Elem] < Object
2182
2215
  #
2183
2216
  # Related: see [Methods for Querying](rdoc-ref:Array@Methods+for+Querying).
2184
2217
  #
2185
- def include?: (Elem object) -> bool
2218
+ def include?: (top object) -> bool
2186
2219
 
2187
2220
  # <!-- rdoc-file=array.c -->
2188
2221
  # Returns the zero-based integer index of a specified element, or `nil`.
2189
2222
  #
2190
2223
  # With only argument `object` given, returns the index of the first element
2191
- # `element` for which `object == element`:
2224
+ # `element` for which <code>object == element</code>:
2192
2225
  #
2193
2226
  # a = [:foo, 'bar', 2, 'bar']
2194
2227
  # a.index('bar') # => 1
@@ -2221,13 +2254,14 @@ class Array[unchecked out Elem] < Object
2221
2254
  # a = ['a', 'b', 'c'] # => ["a", "b", "c"]
2222
2255
  # a.insert(1, :x, :y, :z) # => ["a", :x, :y, :z, "b", "c"]
2223
2256
  #
2224
- # 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>):
2225
2259
  #
2226
2260
  # a = ['a', 'b', 'c'] # => ["a", "b", "c"]
2227
2261
  # a.insert(5, :x, :y, :z) # => ["a", "b", "c", nil, nil, :x, :y, :z]
2228
2262
  #
2229
2263
  # When `index` is negative, inserts `objects` *after* the element at offset
2230
- # `index + self.size`:
2264
+ # <code>index + self.size</code>:
2231
2265
  #
2232
2266
  # a = ['a', 'b', 'c'] # => ["a", "b", "c"]
2233
2267
  # a.insert(-2, :x, :y, :z) # => ["a", "b", :x, :y, :z, "c"]
@@ -2251,8 +2285,8 @@ class Array[unchecked out Elem] < Object
2251
2285
  # - inspect -> new_string
2252
2286
  # - to_s -> new_string
2253
2287
  # -->
2254
- # Returns the new string formed by calling method `#inspect` on each array
2255
- # element:
2288
+ # Returns the new string formed by calling method <code>#inspect</code> on each
2289
+ # array element:
2256
2290
  #
2257
2291
  # a = [:foo, 'bar', 2]
2258
2292
  # a.inspect # => "[:foo, \"bar\", 2]"
@@ -2265,13 +2299,13 @@ class Array[unchecked out Elem] < Object
2265
2299
  # rdoc-file=array.c
2266
2300
  # - intersect?(other_array) -> true or false
2267
2301
  # -->
2268
- # Returns whether `other_array` has at least one element that is `#eql?` to some
2269
- # element of `self`:
2302
+ # Returns whether `other_array` has at least one element that is
2303
+ # <code>#eql?</code> to some element of `self`:
2270
2304
  #
2271
2305
  # [1, 2, 3].intersect?([3, 4, 5]) # => true
2272
2306
  # [1, 2, 3].intersect?([4, 5, 6]) # => false
2273
2307
  #
2274
- # Each element must correctly implement method `#hash`.
2308
+ # Each element must correctly implement method <code>#hash</code>.
2275
2309
  #
2276
2310
  # Related: see [Methods for Querying](rdoc-ref:Array@Methods+for+Querying).
2277
2311
  #
@@ -2281,12 +2315,13 @@ class Array[unchecked out Elem] < Object
2281
2315
  # rdoc-file=array.c
2282
2316
  # - intersection(*other_arrays) -> new_array
2283
2317
  # -->
2284
- # Returns a new array containing each element in `self` that is `#eql?` to at
2285
- # 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:
2286
2321
  #
2287
2322
  # [0, 0, 1, 1, 2, 3].intersection([0, 1, 2], [0, 1, 3]) # => [0, 1]
2288
2323
  #
2289
- # Each element must correctly implement method `#hash`.
2324
+ # Each element must correctly implement method <code>#hash</code>.
2290
2325
  #
2291
2326
  # Order from `self` is preserved:
2292
2327
  #
@@ -2300,16 +2335,17 @@ class Array[unchecked out Elem] < Object
2300
2335
 
2301
2336
  # <!--
2302
2337
  # rdoc-file=array.c
2303
- # - array.join(separator = $,) -> new_string
2338
+ # - join(separator = $,) -> new_string
2304
2339
  # -->
2305
2340
  # Returns the new string formed by joining the converted elements of `self`; for
2306
2341
  # each element `element`:
2307
2342
  #
2308
- # * Converts recursively using `element.join(separator)` if `element` is a
2309
- # `kind_of?(Array)`.
2310
- # * 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>.
2311
2346
  #
2312
- # With no argument given, joins using the output field separator, `$,`:
2347
+ # With no argument given, joins using the output field separator,
2348
+ # <code>$,</code>:
2313
2349
  #
2314
2350
  # a = [:foo, 'bar', 2]
2315
2351
  # $, # => nil
@@ -2432,16 +2468,17 @@ class Array[unchecked out Elem] < Object
2432
2468
  #
2433
2469
  # Does not modify `self`.
2434
2470
  #
2435
- # With no block given, each element in `self` must respond to method `#<=>` with
2436
- # a numeric.
2471
+ # With no block given, each element in `self` must respond to method
2472
+ # <code>#<=></code> with a numeric.
2437
2473
  #
2438
2474
  # With no argument and no block, returns the element in `self` having the
2439
- # maximum value per method `#<=>`:
2475
+ # maximum value per method <code>#<=></code>:
2440
2476
  #
2441
2477
  # [1, 0, 3, 2].max # => 3
2442
2478
  #
2443
2479
  # With non-negative numeric argument `count` and no block, returns a new array
2444
- # with at most `count` elements, in descending order, per method `#<=>`:
2480
+ # with at most `count` elements, in descending order, per method
2481
+ # <code>#<=></code>:
2445
2482
  #
2446
2483
  # [1, 0, 3, 2].max(3) # => [3, 2, 1]
2447
2484
  # [1, 0, 3, 2].max(3.0) # => [3, 2, 1]
@@ -2450,8 +2487,9 @@ class Array[unchecked out Elem] < Object
2450
2487
  #
2451
2488
  # With a block given, the block must return a numeric.
2452
2489
  #
2453
- # With a block and no argument, calls the block `self.size - 1` times to compare
2454
- # 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:
2455
2493
  #
2456
2494
  # ['0', '', '000', '00'].max {|a, b| a.size <=> b.size }
2457
2495
  # # => "000"
@@ -2483,16 +2521,17 @@ class Array[unchecked out Elem] < Object
2483
2521
  #
2484
2522
  # Does not modify `self`.
2485
2523
  #
2486
- # With no block given, each element in `self` must respond to method `#<=>` with
2487
- # a numeric.
2524
+ # With no block given, each element in `self` must respond to method
2525
+ # <code>#<=></code> with a numeric.
2488
2526
  #
2489
2527
  # With no argument and no block, returns the element in `self` having the
2490
- # minimum value per method `#<=>`:
2528
+ # minimum value per method <code>#<=></code>:
2491
2529
  #
2492
2530
  # [1, 0, 3, 2].min # => 0
2493
2531
  #
2494
2532
  # With non-negative numeric argument `count` and no block, returns a new array
2495
- # with at most `count` elements, in ascending order, per method `#<=>`:
2533
+ # with at most `count` elements, in ascending order, per method
2534
+ # <code>#<=></code>:
2496
2535
  #
2497
2536
  # [1, 0, 3, 2].min(3) # => [0, 1, 2]
2498
2537
  # [1, 0, 3, 2].min(3.0) # => [0, 1, 2]
@@ -2501,8 +2540,9 @@ class Array[unchecked out Elem] < Object
2501
2540
  #
2502
2541
  # With a block given, the block must return a numeric.
2503
2542
  #
2504
- # With a block and no argument, calls the block `self.size - 1` times to compare
2505
- # 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:
2506
2546
  #
2507
2547
  # ['0', '', '000', '00'].min {|a, b| a.size <=> b.size }
2508
2548
  # # => ""
@@ -2526,13 +2566,13 @@ class Array[unchecked out Elem] < Object
2526
2566
  # elements from `self`; does not modify `self`.
2527
2567
  #
2528
2568
  # With no block given, the minimum and maximum values are determined using
2529
- # method `#<=>`:
2569
+ # method <code>#<=></code>:
2530
2570
  #
2531
2571
  # [1, 0, 3, 2].minmax # => [0, 3]
2532
2572
  #
2533
2573
  # With a block given, the block must return a numeric; the block is called
2534
- # `self.size - 1` times to compare elements; returns the elements having the
2535
- # 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:
2536
2576
  #
2537
2577
  # ['0', '', '000', '00'].minmax {|a, b| a.size <=> b.size }
2538
2578
  # # => ["", "000"]
@@ -2559,7 +2599,7 @@ class Array[unchecked out Elem] < Object
2559
2599
  # [].none? # => true
2560
2600
  #
2561
2601
  # With argument `object` given, returns `false` if for any element `element`,
2562
- # `object === element`; `true` otherwise:
2602
+ # <code>object === element</code>; `true` otherwise:
2563
2603
  #
2564
2604
  # ['food', 'drink'].none?(/bar/) # => true
2565
2605
  # ['food', 'drink'].none?(/foo/) # => false
@@ -2601,7 +2641,7 @@ class Array[unchecked out Elem] < Object
2601
2641
  # [0, 1, 2].one? {|element| element > 2 } # => false
2602
2642
  #
2603
2643
  # With argument `object` given, returns `true` if for exactly one element
2604
- # `element`, `object === element`; `false` otherwise:
2644
+ # `element`, <code>object === element</code>; `false` otherwise:
2605
2645
  #
2606
2646
  # [0, 1, 2].one?(0) # => true
2607
2647
  # [0, 0, 1].one?(0) # => false
@@ -2619,7 +2659,7 @@ class Array[unchecked out Elem] < Object
2619
2659
  # - pack(template, buffer: nil) -> string
2620
2660
  # -->
2621
2661
  # Formats each element in `self` into a binary string; returns that string. See
2622
- # [Packed Data](rdoc-ref:packed_data.rdoc).
2662
+ # [Packed Data](rdoc-ref:language/packed_data.rdoc).
2623
2663
  #
2624
2664
  def pack: (string fmt, ?buffer: String?) -> String
2625
2665
 
@@ -2631,9 +2671,9 @@ class Array[unchecked out Elem] < Object
2631
2671
  # Iterates over permutations of the elements of `self`; the order of
2632
2672
  # permutations is indeterminate.
2633
2673
  #
2634
- # With a block and an in-range positive integer argument `count` (`0 < count <=
2635
- # self.size`) given, calls the block with each permutation of `self` of size
2636
- # `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`:
2637
2677
  #
2638
2678
  # a = [0, 1, 2]
2639
2679
  # perms = []
@@ -2654,8 +2694,8 @@ class Array[unchecked out Elem] < Object
2654
2694
  # a.permutation(0) {|perm| perms.push(perm) }
2655
2695
  # perms # => [[]]
2656
2696
  #
2657
- # When `count` is out of range (negative or larger than `self.size`), does not
2658
- # call the block:
2697
+ # When `count` is out of range (negative or larger than <code>self.size</code>),
2698
+ # does not call the block:
2659
2699
  #
2660
2700
  # a.permutation(-1) {|permutation| fail 'Cannot happen' }
2661
2701
  # a.permutation(4) {|permutation| fail 'Cannot happen' }
@@ -2792,7 +2832,7 @@ class Array[unchecked out Elem] < Object
2792
2832
  # - rassoc(object) -> found_array or nil
2793
2833
  # -->
2794
2834
  # Returns the first element `ele` in `self` such that `ele` is an array and
2795
- # `ele[1] == object`:
2835
+ # <code>ele[1] == object</code>:
2796
2836
  #
2797
2837
  # a = [{foo: 0}, [2, 4], [4, 5, 6], [4, 5]]
2798
2838
  # a.rassoc(4) # => [2, 4]
@@ -2856,7 +2896,7 @@ class Array[unchecked out Elem] < Object
2856
2896
  #
2857
2897
  # If a positive integer argument `size` is given, calls the block with each
2858
2898
  # `size`-tuple repeated combination of the elements of `self`. The number of
2859
- # combinations is `(size+1)(size+2)/2`.
2899
+ # combinations is <code>(size+1)(size+2)/2</code>.
2860
2900
  #
2861
2901
  # Examples:
2862
2902
  #
@@ -2896,7 +2936,7 @@ class Array[unchecked out Elem] < Object
2896
2936
  #
2897
2937
  # If a positive integer argument `size` is given, calls the block with each
2898
2938
  # `size`-tuple repeated permutation of the elements of `self`. The number of
2899
- # permutations is `self.size**size`.
2939
+ # permutations is <code>self.size**size</code>.
2900
2940
  #
2901
2941
  # Examples:
2902
2942
  #
@@ -2989,13 +3029,39 @@ class Array[unchecked out Elem] < Object
2989
3029
  def reverse_each: () { (Elem item) -> void } -> self
2990
3030
  | () -> ::Enumerator[Elem, self]
2991
3031
 
3032
+ # <!--
3033
+ # rdoc-file=array.c
3034
+ # - rfind(if_none_proc = nil) {|element| ... } -> object or nil
3035
+ # - rfind(if_none_proc = nil) -> enumerator
3036
+ # -->
3037
+ # Returns the last element for which the block returns a truthy value.
3038
+ #
3039
+ # With a block given, calls the block with successive elements of the array in
3040
+ # reverse order; returns the first element for which the block returns a truthy
3041
+ # value:
3042
+ #
3043
+ # [1, 2, 3, 4, 5, 6].rfind {|element| element < 5} # => 4
3044
+ #
3045
+ # If no such element is found, calls `if_none_proc` and returns its return
3046
+ # value.
3047
+ #
3048
+ # [1, 2, 3, 4].rfind(proc {0}) {|element| element < -2} # => 0
3049
+ #
3050
+ # With no block given, returns an Enumerator.
3051
+ #
3052
+ def rfind: () { (Elem) -> boolish } -> Elem?
3053
+ | () -> ::Enumerator[Elem, Elem?]
3054
+ | [T] (Enumerable::_NotFound[T] ifnone) { (Elem) -> boolish } -> (Elem | T)
3055
+ | [T] (Enumerable::_NotFound[T] ifnone) -> ::Enumerator[Elem, Elem | T]
3056
+
2992
3057
  # <!--
2993
3058
  # rdoc-file=array.c
2994
3059
  # - rindex(object) -> integer or nil
2995
3060
  # - rindex {|element| ... } -> integer or nil
2996
3061
  # - rindex -> new_enumerator
2997
3062
  # -->
2998
- # 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>.
2999
3065
  #
3000
3066
  # With argument `object` given, returns the index of the last such element
3001
3067
  # found:
@@ -3034,7 +3100,7 @@ class Array[unchecked out Elem] < Object
3034
3100
  # [0, 1, 2, 3].rotate(2) # => [2, 3, 0, 1]
3035
3101
  # [0, 1, 2, 3].rotate(2.1) # => [2, 3, 0, 1]
3036
3102
  #
3037
- # 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:
3038
3104
  #
3039
3105
  # [0, 1, 2, 3].rotate(22) # => [2, 3, 0, 1]
3040
3106
  #
@@ -3047,7 +3113,8 @@ class Array[unchecked out Elem] < Object
3047
3113
  #
3048
3114
  # [0, 1, 2, 3].rotate(-1) # => [3, 0, 1, 2]
3049
3115
  #
3050
- # 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:
3051
3118
  #
3052
3119
  # [0, 1, 2, 3].rotate(-21) # => [3, 0, 1, 2]
3053
3120
  #
@@ -3068,7 +3135,7 @@ class Array[unchecked out Elem] < Object
3068
3135
  # [0, 1, 2, 3].rotate!(2) # => [2, 3, 0, 1]
3069
3136
  # [0, 1, 2, 3].rotate!(2.1) # => [2, 3, 0, 1]
3070
3137
  #
3071
- # 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:
3072
3139
  #
3073
3140
  # [0, 1, 2, 3].rotate!(21) # => [1, 2, 3, 0]
3074
3141
  #
@@ -3081,7 +3148,8 @@ class Array[unchecked out Elem] < Object
3081
3148
  #
3082
3149
  # [0, 1, 2, 3].rotate!(-1) # => [3, 0, 1, 2]
3083
3150
  #
3084
- # 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:
3085
3153
  #
3086
3154
  # [0, 1, 2, 3].rotate!(-21) # => [3, 0, 1, 2]
3087
3155
  #
@@ -3115,7 +3183,7 @@ class Array[unchecked out Elem] < Object
3115
3183
  #
3116
3184
  # The order of the result array is unrelated to the order of `self`.
3117
3185
  #
3118
- # Returns a new empty `Array` if `self` is empty:
3186
+ # Returns a new empty array if `self` is empty:
3119
3187
  #
3120
3188
  # [].sample(4) # => []
3121
3189
  #
@@ -3124,8 +3192,8 @@ class Array[unchecked out Elem] < Object
3124
3192
  # a = [1, 1, 1, 2, 2, 3]
3125
3193
  # a.sample(a.size) # => [1, 1, 3, 2, 1, 2]
3126
3194
  #
3127
- # Returns no more than `a.size` elements (because no new duplicates are
3128
- # introduced):
3195
+ # Returns no more than <code>a.size</code> elements (because no new duplicates
3196
+ # are introduced):
3129
3197
  #
3130
3198
  # a.sample(50) # => [6, 4, 1, 8, 5, 9, 0, 2, 3, 7]
3131
3199
  #
@@ -3320,50 +3388,52 @@ class Array[unchecked out Elem] < Object
3320
3388
  #
3321
3389
  # If `index` is out of range, returns `nil`.
3322
3390
  #
3323
- # When two Integer arguments `start` and `length` are given, returns a new
3324
- # `Array` of size `length` containing successive elements beginning at offset
3325
- # `start`:
3391
+ # When two Integer arguments `start` and `length` are given, returns a new array
3392
+ # of size `length` containing successive elements beginning at offset `start`:
3326
3393
  #
3327
3394
  # a = [:foo, 'bar', 2]
3328
3395
  # a[0, 2] # => [:foo, "bar"]
3329
3396
  # a[1, 2] # => ["bar", 2]
3330
3397
  #
3331
- # If `start + length` is greater than `self.length`, returns all elements from
3332
- # 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:
3333
3400
  #
3334
3401
  # a = [:foo, 'bar', 2]
3335
3402
  # a[0, 4] # => [:foo, "bar", 2]
3336
3403
  # a[1, 3] # => ["bar", 2]
3337
3404
  # a[2, 2] # => [2]
3338
3405
  #
3339
- # 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.
3340
3408
  #
3341
3409
  # If `length` is negative, returns `nil`.
3342
3410
  #
3343
- # When a single Range argument `range` is given, treats `range.min` as `start`
3344
- # 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:
3345
3413
  #
3346
3414
  # a = [:foo, 'bar', 2]
3347
3415
  # a[0..1] # => [:foo, "bar"]
3348
3416
  # a[1..2] # => ["bar", 2]
3349
3417
  #
3350
- # 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.
3351
3420
  #
3352
- # 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:
3353
3422
  #
3354
3423
  # a = [:foo, 'bar', 2]
3355
3424
  # a[0..-1] # => [:foo, "bar", 2]
3356
3425
  # a[0..-2] # => [:foo, "bar"]
3357
3426
  # a[0..-3] # => [:foo]
3358
3427
  #
3359
- # 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:
3360
3430
  #
3361
3431
  # a = [:foo, 'bar', 2]
3362
3432
  # a[-1..2] # => [2]
3363
3433
  # a[-2..2] # => ["bar", 2]
3364
3434
  # a[-3..2] # => [:foo, "bar", 2]
3365
3435
  #
3366
- # 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`.
3367
3437
  #
3368
3438
  # a = [:foo, 'bar', 2]
3369
3439
  # a[4..1] # => nil
@@ -3371,7 +3441,7 @@ class Array[unchecked out Elem] < Object
3371
3441
  # a[4..-1] # => nil
3372
3442
  #
3373
3443
  # When a single Enumerator::ArithmeticSequence argument `aseq` is given, returns
3374
- # an `Array` of elements corresponding to the indexes produced by the sequence.
3444
+ # an array of elements corresponding to the indexes produced by the sequence.
3375
3445
  #
3376
3446
  # a = ['--', 'data1', '--', 'data2', '--', 'data3']
3377
3447
  # a[(1..).step(2)] # => ["data1", "data2", "data3"]
@@ -3445,42 +3515,43 @@ class Array[unchecked out Elem] < Object
3445
3515
  # a.slice!(5, 1) # => nil
3446
3516
  # a.slice!(-5, 1) # => nil
3447
3517
  #
3448
- # If `start + length` exceeds the array size, removes and returns all elements
3449
- # 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:
3450
3520
  #
3451
3521
  # a = ['a', 'b', 'c', 'd']
3452
3522
  # a.slice!(2, 50) # => ["c", "d"]
3453
3523
  # a # => ["a", "b"]
3454
3524
  #
3455
- # 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.
3456
3527
  #
3457
3528
  # If `length` is negative, returns `nil`.
3458
3529
  #
3459
- # With Range argument `range` given, treats `range.min` as `start` (as above)
3460
- # 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):
3461
3532
  #
3462
3533
  # a = ['a', 'b', 'c', 'd']
3463
3534
  # a.slice!(1..2) # => ["b", "c"]
3464
3535
  # a # => ["a", "d"]
3465
3536
  #
3466
- # If `range.start == a.size`, returns a new empty array:
3537
+ # If <code>range.start == a.size</code>, returns a new empty array:
3467
3538
  #
3468
3539
  # a = ['a', 'b', 'c', 'd']
3469
3540
  # a.slice!(4..5) # => []
3470
3541
  #
3471
- # 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`:
3472
3543
  #
3473
3544
  # a = ['a', 'b', 'c', 'd']
3474
3545
  # a.slice!(5..6) # => nil
3475
3546
  #
3476
- # If `range.start` is negative, calculates the start index by counting backwards
3477
- # 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`:
3478
3549
  #
3479
3550
  # a = ['a', 'b', 'c', 'd']
3480
3551
  # a.slice!(-2..2) # => ["c"]
3481
3552
  #
3482
- # If `range.end` is negative, calculates the end index by counting backwards
3483
- # 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`:
3484
3555
  #
3485
3556
  # a = ['a', 'b', 'c', 'd']
3486
3557
  # a.slice!(0..-2) # => ["a", "b", "c"]
@@ -3498,7 +3569,8 @@ class Array[unchecked out Elem] < Object
3498
3569
  # -->
3499
3570
  # Returns a new array containing the elements of `self`, sorted.
3500
3571
  #
3501
- # With no block given, compares elements using operator `#<=>` (see Object#<=>):
3572
+ # With no block given, compares elements using operator <code>#<=></code> (see
3573
+ # Object#<=>):
3502
3574
  #
3503
3575
  # [0, 2, 3, 1].sort # => [0, 1, 2, 3]
3504
3576
  #
@@ -3518,6 +3590,9 @@ class Array[unchecked out Elem] < Object
3518
3590
  # When the block returns zero, the order for `a` and `b` is indeterminate, and
3519
3591
  # may be unstable.
3520
3592
  #
3593
+ # See an example in Numeric#nonzero? for the idiom to sort more complex
3594
+ # structure.
3595
+ #
3521
3596
  # Related: see [Methods for Fetching](rdoc-ref:Array@Methods+for+Fetching).
3522
3597
  #
3523
3598
  def sort: () -> ::Array[Elem]
@@ -3571,7 +3646,8 @@ class Array[unchecked out Elem] < Object
3571
3646
  # array.each {|element| sum += element }
3572
3647
  # sum
3573
3648
  #
3574
- # 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>.
3575
3651
  #
3576
3652
  # Examples:
3577
3653
  #
@@ -3582,7 +3658,7 @@ class Array[unchecked out Elem] < Object
3582
3658
  # # => [2, 3, :foo, :bar, "foo", "bar"]
3583
3659
  #
3584
3660
  # The `init` value and elements need not be numeric, but must all be
3585
- # `+`-compatible:
3661
+ # <code>+</code>-compatible:
3586
3662
  #
3587
3663
  # # Raises TypeError: Array can't be coerced into Integer.
3588
3664
  # [[:foo, :bar], ['foo', 'bar']].sum(2)
@@ -3647,7 +3723,7 @@ class Array[unchecked out Elem] < Object
3647
3723
  # rdoc-file=array.c
3648
3724
  # - to_a -> self or new_array
3649
3725
  # -->
3650
- # When `self` is an instance of `Array`, returns `self`.
3726
+ # When `self` is an instance of Array, returns `self`.
3651
3727
  #
3652
3728
  # Otherwise, returns a new array containing the elements of `self`:
3653
3729
  #
@@ -3663,7 +3739,7 @@ class Array[unchecked out Elem] < Object
3663
3739
 
3664
3740
  # <!--
3665
3741
  # rdoc-file=array.c
3666
- # - array.to_ary -> self
3742
+ # - to_ary -> self
3667
3743
  # -->
3668
3744
  # Returns `self`.
3669
3745
  #
@@ -3697,8 +3773,8 @@ class Array[unchecked out Elem] < Object
3697
3773
  | [T, S] () { (Elem) -> [ T, S ] } -> Hash[T, S]
3698
3774
 
3699
3775
  # <!-- rdoc-file=array.c -->
3700
- # Returns the new string formed by calling method `#inspect` on each array
3701
- # element:
3776
+ # Returns the new string formed by calling method <code>#inspect</code> on each
3777
+ # array element:
3702
3778
  #
3703
3779
  # a = [:foo, 'bar', 2]
3704
3780
  # a.inspect # => "[:foo, \"bar\", 2]"
@@ -3728,7 +3804,7 @@ class Array[unchecked out Elem] < Object
3728
3804
  # - union(*other_arrays) -> new_array
3729
3805
  # -->
3730
3806
  # Returns a new array that is the union of the elements of `self` and all given
3731
- # arrays `other_arrays`; items are compared using `eql?`:
3807
+ # arrays `other_arrays`; items are compared using <code>eql?</code>:
3732
3808
  #
3733
3809
  # [0, 1, 2, 3].union([4, 5], [6, 7]) # => [0, 1, 2, 3, 4, 5, 6, 7]
3734
3810
  #
@@ -3755,15 +3831,15 @@ class Array[unchecked out Elem] < Object
3755
3831
  # duplicates, the first occurrence always being retained.
3756
3832
  #
3757
3833
  # With no block given, identifies and omits duplicate elements using method
3758
- # `eql?` to compare elements:
3834
+ # <code>eql?</code> to compare elements:
3759
3835
  #
3760
3836
  # a = [0, 0, 1, 1, 2, 2]
3761
3837
  # a.uniq # => [0, 1, 2]
3762
3838
  #
3763
3839
  # With a block given, calls the block for each element; identifies and omits
3764
- # "duplicate" elements using method `eql?` to compare *block return values*;
3765
- # that is, an element is a duplicate if its block return value is the same as
3766
- # 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:
3767
3843
  #
3768
3844
  # a = ['a', 'aa', 'aaa', 'b', 'bb', 'bbb']
3769
3845
  # a.uniq {|element| element.size } # => ["a", "aa", "aaa"]
@@ -3781,17 +3857,17 @@ class Array[unchecked out Elem] < Object
3781
3857
  # Removes duplicate elements from `self`, the first occurrence always being
3782
3858
  # retained; returns `self` if any elements removed, `nil` otherwise.
3783
3859
  #
3784
- # With no block given, identifies and removes elements using method `eql?` to
3785
- # compare elements:
3860
+ # With no block given, identifies and removes elements using method
3861
+ # <code>eql?</code> to compare elements:
3786
3862
  #
3787
3863
  # a = [0, 0, 1, 1, 2, 2]
3788
3864
  # a.uniq! # => [0, 1, 2]
3789
3865
  # a.uniq! # => nil
3790
3866
  #
3791
3867
  # With a block given, calls the block for each element; identifies and omits
3792
- # "duplicate" elements using method `eql?` to compare *block return values*;
3793
- # that is, an element is a duplicate if its block return value is the same as
3794
- # 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:
3795
3871
  #
3796
3872
  # a = ['a', 'aa', 'aaa', 'b', 'bb', 'bbb']
3797
3873
  # a.uniq! {|element| element.size } # => ["a", "aa", "aaa"]
@@ -3857,13 +3933,13 @@ class Array[unchecked out Elem] < Object
3857
3933
  # For each numeric specifier `index`, includes an element:
3858
3934
  #
3859
3935
  # * For each non-negative numeric specifier `index` that is in-range (less
3860
- # than `self.size`), includes the element at offset `index`:
3936
+ # than <code>self.size</code>), includes the element at offset `index`:
3861
3937
  #
3862
3938
  # a.values_at(0, 2) # => ["a", "c"]
3863
3939
  # a.values_at(0.1, 2.9) # => ["a", "c"]
3864
3940
  #
3865
3941
  # * For each negative numeric `index` that is in-range (greater than or equal
3866
- # to `- self.size`), counts backwards from the end of `self`:
3942
+ # to <code>- self.size</code>), counts backwards from the end of `self`:
3867
3943
  #
3868
3944
  # a.values_at(-1, -4) # => ["d", "a"]
3869
3945
  #
@@ -3875,37 +3951,41 @@ class Array[unchecked out Elem] < Object
3875
3951
  #
3876
3952
  # a.values_at(4, -5) # => [nil, nil]
3877
3953
  #
3878
- # For each Range specifier `range`, includes elements according to `range.begin`
3879
- # and `range.end`:
3954
+ # For each Range specifier `range`, includes elements according to
3955
+ # <code>range.begin</code> and <code>range.end</code>:
3880
3956
  #
3881
- # * If both `range.begin` and `range.end` are non-negative and in-range (less
3882
- # than `self.size`), includes elements from index `range.begin` through
3883
- # `range.end - 1` (if `range.exclude_end?`), or through `range.end`
3884
- # (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):
3885
3962
  #
3886
3963
  # a.values_at(1..2) # => ["b", "c"]
3887
3964
  # a.values_at(1...2) # => ["b"]
3888
3965
  #
3889
- # * If `range.begin` is negative and in-range (greater than or equal to `-
3890
- # 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`:
3891
3969
  #
3892
3970
  # a.values_at(-2..3) # => ["c", "d"]
3893
3971
  #
3894
- # * 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:
3895
3974
  #
3896
3975
  # a.values_at(-5..3) # Raises RangeError.
3897
3976
  #
3898
- # * If `range.end` is positive and out-of-range, extends the returned array
3899
- # with `nil` elements:
3977
+ # * If <code>range.end</code> is positive and out-of-range, extends the
3978
+ # returned array with `nil` elements:
3900
3979
  #
3901
3980
  # a.values_at(1..5) # => ["b", "c", "d", nil, nil]
3902
3981
  #
3903
- # * If `range.end` is negative and in-range, counts backwards from the end of
3904
- # `self`:
3982
+ # * If <code>range.end</code> is negative and in-range, counts backwards from
3983
+ # the end of `self`:
3905
3984
  #
3906
3985
  # a.values_at(1..-2) # => ["b", "c"]
3907
3986
  #
3908
- # * 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:
3909
3989
  #
3910
3990
  # a.values_at(1..-5) # => []
3911
3991
  #
@@ -3934,8 +4014,8 @@ class Array[unchecked out Elem] < Object
3934
4014
  #
3935
4015
  # Returned:
3936
4016
  #
3937
- # * The outer array is of size `self.size`.
3938
- # * 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>.
3939
4019
  # * The *nth* sub-array contains (in order):
3940
4020
  #
3941
4021
  # * The *nth* element of `self`.
@@ -4008,8 +4088,8 @@ class Array[unchecked out Elem] < Object
4008
4088
  # [:c3, :b3, :a3]]
4009
4089
  #
4010
4090
  # For an **object** in **other_arrays** that is not actually an array, forms the
4011
- # the "other array" as `object.to_ary`, if defined, or as `object.each.to_a`
4012
- # otherwise.
4091
+ # "other array" as <code>object.to_ary</code>, if defined, or as
4092
+ # <code>object.each.to_a</code> otherwise.
4013
4093
  #
4014
4094
  # Related: see [Methods for Converting](rdoc-ref:Array@Methods+for+Converting).
4015
4095
  #
@@ -4023,7 +4103,7 @@ class Array[unchecked out Elem] < Object
4023
4103
  # - self | other_array -> new_array
4024
4104
  # -->
4025
4105
  # Returns the union of `self` and `other_array`; duplicates are removed; order
4026
- # is preserved; items are compared using `eql?`:
4106
+ # is preserved; items are compared using <code>eql?</code>:
4027
4107
  #
4028
4108
  # [0, 1] | [2, 3] # => [0, 1, 2, 3]
4029
4109
  # [0, 1, 1] | [2, 2, 3] # => [0, 1, 2, 3]