rbs 4.0.0.dev.4 → 4.1.0.pre.2

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 (306) hide show
  1. checksums.yaml +4 -4
  2. data/.clang-format +1 -0
  3. data/.github/dependabot.yml +16 -14
  4. data/.github/workflows/bundle-update.yml +63 -0
  5. data/.github/workflows/c-check.yml +21 -11
  6. data/.github/workflows/comments.yml +5 -3
  7. data/.github/workflows/dependabot.yml +2 -2
  8. data/.github/workflows/jruby.yml +67 -0
  9. data/.github/workflows/milestone.yml +83 -0
  10. data/.github/workflows/ruby.yml +63 -24
  11. data/.github/workflows/rust.yml +184 -0
  12. data/.github/workflows/truffleruby.yml +54 -0
  13. data/.github/workflows/typecheck.yml +5 -2
  14. data/.github/workflows/wasm.yml +53 -0
  15. data/.github/workflows/windows.yml +8 -2
  16. data/.gitignore +11 -0
  17. data/.rubocop.yml +1 -1
  18. data/CHANGELOG.md +357 -0
  19. data/README.md +4 -4
  20. data/Rakefile +365 -33
  21. data/Steepfile +8 -0
  22. data/config.yml +450 -24
  23. data/core/array.rbs +443 -363
  24. data/core/basic_object.rbs +9 -8
  25. data/core/binding.rbs +0 -2
  26. data/core/builtin.rbs +9 -8
  27. data/core/class.rbs +11 -8
  28. data/core/comparable.rbs +55 -34
  29. data/core/complex.rbs +104 -78
  30. data/core/dir.rbs +61 -49
  31. data/core/encoding.rbs +12 -15
  32. data/core/enumerable.rbs +288 -196
  33. data/core/enumerator/arithmetic_sequence.rbs +70 -0
  34. data/core/enumerator/product.rbs +5 -5
  35. data/core/enumerator.rbs +91 -28
  36. data/core/errno.rbs +11 -2
  37. data/core/errors.rbs +58 -29
  38. data/core/exception.rbs +13 -13
  39. data/core/fiber.rbs +74 -54
  40. data/core/file.rbs +260 -1151
  41. data/core/file_constants.rbs +463 -0
  42. data/core/file_stat.rbs +534 -0
  43. data/core/file_test.rbs +3 -3
  44. data/core/float.rbs +257 -92
  45. data/core/gc.rbs +425 -281
  46. data/core/hash.rbs +1151 -829
  47. data/core/integer.rbs +156 -195
  48. data/core/io/buffer.rbs +53 -42
  49. data/core/io/wait.rbs +13 -35
  50. data/core/io.rbs +216 -150
  51. data/core/kernel.rbs +239 -163
  52. data/core/marshal.rbs +4 -4
  53. data/core/match_data.rbs +15 -13
  54. data/core/math.rbs +107 -66
  55. data/core/method.rbs +69 -33
  56. data/core/module.rbs +302 -150
  57. data/core/nil_class.rbs +7 -6
  58. data/core/numeric.rbs +77 -63
  59. data/core/object.rbs +9 -11
  60. data/core/object_space/weak_key_map.rbs +7 -7
  61. data/core/object_space.rbs +30 -23
  62. data/core/pathname.rbs +1322 -0
  63. data/core/proc.rbs +95 -58
  64. data/core/process.rbs +222 -202
  65. data/core/ractor.rbs +371 -515
  66. data/core/random.rbs +21 -3
  67. data/core/range.rbs +181 -79
  68. data/core/rational.rbs +60 -89
  69. data/core/rbs/ops.rbs +154 -0
  70. data/core/rbs/unnamed/argf.rbs +63 -56
  71. data/core/rbs/unnamed/env_class.rbs +19 -14
  72. data/core/rbs/unnamed/main_class.rbs +123 -0
  73. data/core/rbs/unnamed/random.rbs +11 -118
  74. data/core/regexp.rbs +258 -214
  75. data/core/ruby.rbs +53 -0
  76. data/core/ruby_vm.rbs +78 -34
  77. data/core/rubygems/config_file.rbs +5 -5
  78. data/core/rubygems/errors.rbs +4 -71
  79. data/core/rubygems/requirement.rbs +5 -5
  80. data/core/rubygems/rubygems.rbs +16 -82
  81. data/core/rubygems/version.rbs +2 -3
  82. data/core/set.rbs +493 -363
  83. data/core/signal.rbs +26 -16
  84. data/core/string.rbs +3234 -1285
  85. data/core/struct.rbs +43 -42
  86. data/core/symbol.rbs +41 -34
  87. data/core/thread.rbs +141 -73
  88. data/core/time.rbs +81 -50
  89. data/core/trace_point.rbs +41 -35
  90. data/core/true_class.rbs +2 -2
  91. data/core/unbound_method.rbs +24 -16
  92. data/core/warning.rbs +7 -7
  93. data/docs/CONTRIBUTING.md +2 -1
  94. data/docs/aliases.md +79 -0
  95. data/docs/collection.md +3 -3
  96. data/docs/config.md +171 -0
  97. data/docs/encoding.md +56 -0
  98. data/docs/gem.md +0 -1
  99. data/docs/inline.md +634 -0
  100. data/docs/rbs_by_example.md +20 -20
  101. data/docs/rust.md +96 -0
  102. data/docs/sigs.md +3 -3
  103. data/docs/syntax.md +48 -18
  104. data/docs/type_fingerprint.md +21 -0
  105. data/docs/wasm_serialization.md +80 -0
  106. data/exe/rbs +1 -1
  107. data/ext/rbs_extension/ast_translation.c +1441 -671
  108. data/ext/rbs_extension/ast_translation.h +7 -0
  109. data/ext/rbs_extension/class_constants.c +18 -2
  110. data/ext/rbs_extension/class_constants.h +9 -0
  111. data/ext/rbs_extension/extconf.rb +6 -1
  112. data/ext/rbs_extension/legacy_location.c +33 -56
  113. data/ext/rbs_extension/legacy_location.h +37 -0
  114. data/ext/rbs_extension/main.c +183 -39
  115. data/include/rbs/ast.h +597 -297
  116. data/include/rbs/defines.h +40 -0
  117. data/include/rbs/lexer.h +31 -11
  118. data/include/rbs/location.h +25 -44
  119. data/include/rbs/parser.h +6 -6
  120. data/include/rbs/serialize.h +39 -0
  121. data/include/rbs/string.h +0 -2
  122. data/include/rbs/util/rbs_allocator.h +34 -13
  123. data/include/rbs/util/rbs_assert.h +12 -1
  124. data/include/rbs/util/rbs_constant_pool.h +0 -3
  125. data/include/rbs/util/rbs_encoding.h +2 -0
  126. data/include/rbs/util/rbs_unescape.h +2 -1
  127. data/include/rbs.h +8 -0
  128. data/lib/rbs/annotate/rdoc_annotator.rb +27 -31
  129. data/lib/rbs/ast/annotation.rb +1 -1
  130. data/lib/rbs/ast/comment.rb +1 -1
  131. data/lib/rbs/ast/declarations.rb +10 -10
  132. data/lib/rbs/ast/members.rb +14 -14
  133. data/lib/rbs/ast/ruby/annotations.rb +335 -3
  134. data/lib/rbs/ast/ruby/comment_block.rb +30 -4
  135. data/lib/rbs/ast/ruby/declarations.rb +209 -4
  136. data/lib/rbs/ast/ruby/helpers/constant_helper.rb +4 -0
  137. data/lib/rbs/ast/ruby/helpers/location_helper.rb +1 -1
  138. data/lib/rbs/ast/ruby/members.rb +571 -22
  139. data/lib/rbs/ast/type_param.rb +24 -4
  140. data/lib/rbs/buffer.rb +66 -24
  141. data/lib/rbs/cli/diff.rb +16 -15
  142. data/lib/rbs/cli/validate.rb +38 -106
  143. data/lib/rbs/cli.rb +55 -24
  144. data/lib/rbs/collection/config/lockfile_generator.rb +28 -3
  145. data/lib/rbs/collection/sources/git.rb +7 -0
  146. data/lib/rbs/definition.rb +1 -1
  147. data/lib/rbs/definition_builder/ancestor_builder.rb +62 -9
  148. data/lib/rbs/definition_builder/method_builder.rb +32 -6
  149. data/lib/rbs/definition_builder.rb +147 -25
  150. data/lib/rbs/diff.rb +7 -1
  151. data/lib/rbs/environment.rb +235 -75
  152. data/lib/rbs/environment_loader.rb +0 -6
  153. data/lib/rbs/errors.rb +27 -18
  154. data/lib/rbs/inline_parser.rb +377 -15
  155. data/lib/rbs/location_aux.rb +1 -1
  156. data/lib/rbs/locator.rb +5 -1
  157. data/lib/rbs/method_type.rb +5 -3
  158. data/lib/rbs/namespace.rb +47 -11
  159. data/lib/rbs/parser_aux.rb +20 -7
  160. data/lib/rbs/prototype/helpers.rb +57 -0
  161. data/lib/rbs/prototype/rb.rb +3 -28
  162. data/lib/rbs/prototype/rbi.rb +3 -20
  163. data/lib/rbs/prototype/runtime.rb +10 -0
  164. data/lib/rbs/resolver/constant_resolver.rb +2 -2
  165. data/lib/rbs/resolver/type_name_resolver.rb +120 -44
  166. data/lib/rbs/rewriter.rb +70 -0
  167. data/lib/rbs/subtractor.rb +3 -1
  168. data/lib/rbs/test/type_check.rb +25 -3
  169. data/lib/rbs/type_name.rb +34 -14
  170. data/lib/rbs/types.rb +88 -78
  171. data/lib/rbs/unit_test/type_assertions.rb +44 -8
  172. data/lib/rbs/validator.rb +2 -2
  173. data/lib/rbs/version.rb +1 -1
  174. data/lib/rbs/wasm/deserializer.rb +213 -0
  175. data/lib/rbs/wasm/location.rb +61 -0
  176. data/lib/rbs/wasm/parser.rb +137 -0
  177. data/lib/rbs/wasm/runtime.rb +217 -0
  178. data/lib/rbs/wasm/serialization_schema.rb +110 -0
  179. data/lib/rbs.rb +13 -2
  180. data/lib/rdoc/discover.rb +1 -1
  181. data/lib/rdoc_plugin/parser.rb +1 -1
  182. data/rbs.gemspec +24 -6
  183. data/schema/typeParam.json +17 -1
  184. data/sig/annotate/rdoc_annotater.rbs +12 -9
  185. data/sig/ast/ruby/annotations.rbs +364 -4
  186. data/sig/ast/ruby/comment_block.rbs +8 -0
  187. data/sig/ast/ruby/declarations.rbs +102 -4
  188. data/sig/ast/ruby/members.rbs +128 -2
  189. data/sig/buffer.rbs +19 -1
  190. data/sig/cli/diff.rbs +5 -11
  191. data/sig/cli/validate.rbs +12 -8
  192. data/sig/cli.rbs +18 -18
  193. data/sig/collection/config/lockfile_generator.rbs +2 -0
  194. data/sig/definition.rbs +6 -1
  195. data/sig/definition_builder.rbs +2 -0
  196. data/sig/environment.rbs +70 -12
  197. data/sig/errors.rbs +13 -14
  198. data/sig/inline_parser.rbs +41 -2
  199. data/sig/locator.rbs +0 -2
  200. data/sig/manifest.yaml +0 -2
  201. data/sig/method_builder.rbs +3 -1
  202. data/sig/namespace.rbs +20 -0
  203. data/sig/parser.rbs +41 -13
  204. data/sig/prototype/helpers.rbs +2 -0
  205. data/sig/resolver/type_name_resolver.rbs +36 -10
  206. data/sig/rewriter.rbs +45 -0
  207. data/sig/source.rbs +3 -3
  208. data/sig/type_param.rbs +13 -8
  209. data/sig/typename.rbs +15 -0
  210. data/sig/types.rbs +6 -7
  211. data/sig/unit_test/spy.rbs +0 -8
  212. data/sig/unit_test/type_assertions.rbs +15 -0
  213. data/sig/wasm/deserializer.rbs +66 -0
  214. data/sig/wasm/serialization_schema.rbs +13 -0
  215. data/src/ast.c +443 -162
  216. data/src/lexer.c +1415 -1313
  217. data/src/lexer.re +4 -0
  218. data/src/lexstate.c +63 -37
  219. data/src/location.c +7 -47
  220. data/src/parser.c +1032 -521
  221. data/src/serialize.c +958 -0
  222. data/src/string.c +0 -48
  223. data/src/util/rbs_allocator.c +89 -74
  224. data/src/util/rbs_assert.c +1 -1
  225. data/src/util/rbs_buffer.c +2 -2
  226. data/src/util/rbs_constant_pool.c +10 -14
  227. data/src/util/rbs_encoding.c +4 -8
  228. data/src/util/rbs_unescape.c +56 -20
  229. data/stdlib/abbrev/0/array.rbs +1 -1
  230. data/stdlib/bigdecimal/0/big_decimal.rbs +116 -98
  231. data/stdlib/bigdecimal-math/0/big_math.rbs +169 -8
  232. data/stdlib/cgi/0/core.rbs +9 -393
  233. data/stdlib/cgi/0/manifest.yaml +1 -0
  234. data/stdlib/cgi-escape/0/escape.rbs +171 -0
  235. data/stdlib/coverage/0/coverage.rbs +7 -4
  236. data/stdlib/csv/0/csv.rbs +5 -5
  237. data/stdlib/date/0/date.rbs +92 -79
  238. data/stdlib/date/0/date_time.rbs +25 -24
  239. data/stdlib/delegate/0/delegator.rbs +10 -7
  240. data/stdlib/did_you_mean/0/did_you_mean.rbs +17 -16
  241. data/stdlib/digest/0/digest.rbs +111 -1
  242. data/stdlib/erb/0/erb.rbs +748 -347
  243. data/stdlib/etc/0/etc.rbs +73 -54
  244. data/stdlib/fileutils/0/fileutils.rbs +179 -160
  245. data/stdlib/forwardable/0/forwardable.rbs +13 -10
  246. data/stdlib/io-console/0/io-console.rbs +2 -2
  247. data/stdlib/json/0/json.rbs +223 -142
  248. data/stdlib/monitor/0/monitor.rbs +3 -3
  249. data/stdlib/net-http/0/net-http.rbs +162 -134
  250. data/stdlib/objspace/0/objspace.rbs +17 -34
  251. data/stdlib/open-uri/0/open-uri.rbs +48 -8
  252. data/stdlib/open3/0/open3.rbs +469 -10
  253. data/stdlib/openssl/0/openssl.rbs +482 -364
  254. data/stdlib/optparse/0/optparse.rbs +26 -17
  255. data/stdlib/pathname/0/pathname.rbs +11 -1381
  256. data/stdlib/pp/0/pp.rbs +9 -8
  257. data/stdlib/prettyprint/0/prettyprint.rbs +7 -7
  258. data/stdlib/pstore/0/pstore.rbs +35 -30
  259. data/stdlib/psych/0/psych.rbs +65 -12
  260. data/stdlib/psych/0/store.rbs +2 -4
  261. data/stdlib/pty/0/pty.rbs +9 -6
  262. data/stdlib/random-formatter/0/random-formatter.rbs +277 -0
  263. data/stdlib/rdoc/0/code_object.rbs +2 -1
  264. data/stdlib/rdoc/0/parser.rbs +1 -1
  265. data/stdlib/rdoc/0/rdoc.rbs +1 -1
  266. data/stdlib/rdoc/0/store.rbs +1 -1
  267. data/stdlib/resolv/0/resolv.rbs +26 -69
  268. data/stdlib/ripper/0/ripper.rbs +22 -19
  269. data/stdlib/securerandom/0/manifest.yaml +2 -0
  270. data/stdlib/securerandom/0/securerandom.rbs +7 -20
  271. data/stdlib/shellwords/0/shellwords.rbs +3 -3
  272. data/stdlib/singleton/0/singleton.rbs +3 -0
  273. data/stdlib/socket/0/addrinfo.rbs +7 -7
  274. data/stdlib/socket/0/basic_socket.rbs +3 -3
  275. data/stdlib/socket/0/ip_socket.rbs +10 -8
  276. data/stdlib/socket/0/socket.rbs +23 -10
  277. data/stdlib/socket/0/tcp_server.rbs +1 -1
  278. data/stdlib/socket/0/tcp_socket.rbs +11 -3
  279. data/stdlib/socket/0/udp_socket.rbs +1 -1
  280. data/stdlib/socket/0/unix_server.rbs +1 -1
  281. data/stdlib/stringio/0/stringio.rbs +1209 -95
  282. data/stdlib/strscan/0/string_scanner.rbs +101 -80
  283. data/stdlib/tempfile/0/tempfile.rbs +25 -21
  284. data/stdlib/time/0/time.rbs +8 -6
  285. data/stdlib/timeout/0/timeout.rbs +63 -7
  286. data/stdlib/tsort/0/cyclic.rbs +4 -1
  287. data/stdlib/tsort/0/interfaces.rbs +8 -8
  288. data/stdlib/tsort/0/tsort.rbs +16 -15
  289. data/stdlib/uri/0/common.rbs +42 -20
  290. data/stdlib/uri/0/file.rbs +3 -3
  291. data/stdlib/uri/0/generic.rbs +26 -18
  292. data/stdlib/uri/0/http.rbs +2 -2
  293. data/stdlib/uri/0/ldap.rbs +2 -2
  294. data/stdlib/uri/0/mailto.rbs +3 -3
  295. data/stdlib/uri/0/rfc2396_parser.rbs +12 -12
  296. data/stdlib/zlib/0/deflate.rbs +4 -3
  297. data/stdlib/zlib/0/gzip_reader.rbs +8 -8
  298. data/stdlib/zlib/0/gzip_writer.rbs +14 -12
  299. data/stdlib/zlib/0/inflate.rbs +1 -1
  300. data/stdlib/zlib/0/need_dict.rbs +1 -1
  301. data/stdlib/zlib/0/zstream.rbs +1 -0
  302. data/wasm/README.md +59 -0
  303. data/wasm/rbs_wasm.c +411 -0
  304. metadata +56 -8
  305. data/.vscode/extensions.json +0 -5
  306. data/.vscode/settings.json +0 -19
data/core/enumerable.rbs CHANGED
@@ -16,8 +16,8 @@
16
16
  # These methods return information about the Enumerable other than the elements
17
17
  # themselves:
18
18
  #
19
- # * #member? (aliased as #include?): Returns `true` if `self == object`,
20
- # `false` otherwise.
19
+ # * #member? (aliased as #include?): Returns `true` if <code>self ==
20
+ # object</code>, `false` otherwise.
21
21
  # * #all?: Returns `true` if all elements meet a specified criterion; `false`
22
22
  # otherwise.
23
23
  # * #any?: Returns `true` if any element meets a specified criterion; `false`
@@ -35,7 +35,7 @@
35
35
  #
36
36
  # These methods return entries from the Enumerable, without modifying it:
37
37
  #
38
- # *Leading, trailing, or all elements*:
38
+ # <em>Leading, trailing, or all elements</em>:
39
39
  #
40
40
  # * #to_a (aliased as #entries): Returns all elements.
41
41
  # * #first: Returns the first element or leading elements.
@@ -47,9 +47,9 @@
47
47
  # *Minimum and maximum value elements*:
48
48
  #
49
49
  # * #min: Returns the elements whose values are smallest among the elements,
50
- # as determined by `#<=>` or a given block.
50
+ # as determined by <code>#<=></code> or a given block.
51
51
  # * #max: Returns the elements whose values are largest among the elements, as
52
- # determined by `#<=>` or a given block.
52
+ # determined by <code>#<=></code> or a given block.
53
53
  # * #minmax: Returns a 2-element Array containing the smallest and largest
54
54
  # elements.
55
55
  # * #min_by: Returns the smallest element, as determined by the given block.
@@ -57,7 +57,7 @@
57
57
  # * #minmax_by: Returns the smallest and largest elements, as determined by
58
58
  # the given block.
59
59
  #
60
- # *Groups, slices, and partitions*:
60
+ # <em>Groups, slices, and partitions</em>:
61
61
  #
62
62
  # * #group_by: Returns a Hash that partitions the elements into groups.
63
63
  # * #partition: Returns elements partitioned into two new Arrays, as
@@ -89,7 +89,8 @@
89
89
  #
90
90
  # These methods return elements in sorted order:
91
91
  #
92
- # * #sort: Returns the elements, sorted by `#<=>` or the given block.
92
+ # * #sort: Returns the elements, sorted by <code>#<=></code> or the given
93
+ # block.
93
94
  # * #sort_by: Returns the elements, sorted by the given block.
94
95
  #
95
96
  # ### Methods for Iterating
@@ -114,11 +115,11 @@
114
115
  # by the block.
115
116
  # * #grep: Returns elements selected by a given object or objects returned by
116
117
  # a given block.
117
- # * #grep_v: Returns elements selected by a given object or objects returned
118
- # by a given block.
118
+ # * #grep_v: Returns elements not selected by a given object or objects
119
+ # returned by a given block.
119
120
  # * #inject (aliased as #reduce): Returns the object formed by combining all
120
121
  # elements.
121
- # * #sum: Returns the sum of the elements, using method `+`.
122
+ # * #sum: Returns the sum of the elements, using method <code>+</code>.
122
123
  # * #zip: Combines each element with elements from other enumerables; returns
123
124
  # the n-tuples or calls the block with each.
124
125
  # * #cycle: Calls the block with each element, cycling repeatedly.
@@ -131,8 +132,9 @@
131
132
  #
132
133
  # include Enumerable
133
134
  #
134
- # * Implement method `#each` which must yield successive elements of the
135
- # collection. The method will be called by almost any Enumerable method.
135
+ # * Implement method <code>#each</code> which must yield successive elements
136
+ # of the collection. The method will be called by almost any Enumerable
137
+ # method.
136
138
  #
137
139
  # Example:
138
140
  #
@@ -173,13 +175,15 @@
173
175
  # * CSV::Row
174
176
  # * Set
175
177
  #
176
- # Virtually all methods in Enumerable call method `#each` in the including
177
- # class:
178
+ # Virtually all methods in Enumerable call method <code>#each</code> in the
179
+ # including class:
178
180
  #
179
- # * `Hash#each` yields the next key-value pair as a 2-element Array.
180
- # * `Struct#each` yields the next name-value pair as a 2-element Array.
181
- # * For the other classes above, `#each` yields the next object from the
182
- # collection.
181
+ # * <code>Hash#each</code> yields the next key-value pair as a 2-element
182
+ # Array.
183
+ # * <code>Struct#each</code> yields the next name-value pair as a 2-element
184
+ # Array.
185
+ # * For the other classes above, <code>#each</code> yields the next object
186
+ # from the collection.
183
187
  #
184
188
  # ## About the Examples
185
189
  #
@@ -191,7 +195,83 @@
191
195
  # usage would not make sense, and so it is not shown. Example: #tally would
192
196
  # find exactly one of each Hash entry.
193
197
  #
194
- module Enumerable[unchecked out Elem] : _Each[Elem]
198
+ # ## Extended Methods
199
+ #
200
+ # A Enumerable class may define extended methods. This section describes the
201
+ # standard behavior of extension methods for reference purposes.
202
+ #
203
+ # ### #size
204
+ #
205
+ # Enumerator has a #size method. It uses the size function argument passed to
206
+ # <code>Enumerator.new</code>.
207
+ #
208
+ # e = Enumerator.new(-> { 3 }) {|y| p y; y.yield :a; y.yield :b; y.yield :c; :z }
209
+ # p e.size #=> 3
210
+ # p e.next #=> :a
211
+ # p e.next #=> :b
212
+ # p e.next #=> :c
213
+ # begin
214
+ # e.next
215
+ # rescue StopIteration
216
+ # p $!.result #=> :z
217
+ # end
218
+ #
219
+ # The result of the size function should represent the number of iterations
220
+ # (i.e., the number of times Enumerator::Yielder#yield is called). In the above
221
+ # example, the block calls #yield three times, and the size function, +-> { 3
222
+ # }+, returns 3 accordingly. The result of the size function can be an integer,
223
+ # <code>Float::INFINITY</code>, or `nil`. An integer means the exact number of
224
+ # times #yield will be called, as shown above. <code>Float::INFINITY</code>
225
+ # indicates an infinite number of #yield calls. `nil` means the number of #yield
226
+ # calls is difficult or impossible to determine.
227
+ #
228
+ # Many iteration methods return an Enumerator object with an appropriate size
229
+ # function if no block is given.
230
+ #
231
+ # Examples:
232
+ #
233
+ # ["a", "b", "c"].each.size #=> 3
234
+ # {a: "x", b: "y", c: "z"}.each.size #=> 3
235
+ # (0..20).to_a.permutation.size #=> 51090942171709440000
236
+ # loop.size #=> Float::INFINITY
237
+ # (1..100).drop_while.size #=> nil # size depends on the block's behavior
238
+ # STDIN.each.size #=> nil # cannot be computed without consuming input
239
+ # File.open("/etc/resolv.conf").each.size #=> nil # cannot be computed without reading the file
240
+ #
241
+ # The behavior of #size for Range-based enumerators depends on the #begin
242
+ # element:
243
+ #
244
+ # * If the #begin element is an Integer, the #size method returns an Integer
245
+ # or <code>Float::INFINITY</code>.
246
+ # * If the #begin element is an object with a #succ method (other than
247
+ # Integer), #size returns `nil`. (Computing the size would require
248
+ # repeatedly calling #succ, which may be too slow.)
249
+ # * If the #begin element does not have a #succ method, #size raises a
250
+ # TypeError.
251
+ #
252
+ # Examples:
253
+ #
254
+ # (10..42).each.size #=> 33
255
+ # (10..42.9).each.size #=> 33 (the #end element may be a non-integer numeric)
256
+ # (10..).each.size #=> Float::INFINITY
257
+ # ("a".."z").each.size #=> nil
258
+ # ("a"..).each.size #=> nil
259
+ # (1.0..9.0).each.size # raises TypeError (Float does not have #succ)
260
+ # (..10).each.size # raises TypeError (beginless range has nil as its #begin)
261
+ #
262
+ # The Enumerable module itself does not define a #size method. A class that
263
+ # includes Enumerable may define its own #size method. It is recommended that
264
+ # such a #size method be consistent with Enumerator#size.
265
+ #
266
+ # Array and Hash implement #size and return values consistent with
267
+ # Enumerator#size. IO and Dir do not define #size, which is also consistent
268
+ # because the corresponding enumerator's size function returns `nil`.
269
+ #
270
+ # However, it is not strictly required for a class's #size method to match
271
+ # Enumerator#size. For example, File#size returns the number of bytes in the
272
+ # file, not the number of lines.
273
+ #
274
+ module Enumerable[unchecked out E] : _Each[E]
195
275
  %a{private}
196
276
  interface _Pattern
197
277
  def ===: (untyped) -> bool
@@ -216,7 +296,7 @@ module Enumerable[unchecked out Elem] : _Each[Elem]
216
296
  # [].all? # => true
217
297
  #
218
298
  # With argument `pattern` and no block, returns whether for each element
219
- # `element`, `pattern === element`:
299
+ # `element`, <code>pattern === element</code>:
220
300
  #
221
301
  # (1..4).all?(Integer) # => true
222
302
  # (1..4).all?(Numeric) # => true
@@ -240,7 +320,7 @@ module Enumerable[unchecked out Elem] : _Each[Elem]
240
320
  #
241
321
  def all?: () -> bool
242
322
  | (_Pattern) -> bool
243
- | () { (Elem) -> boolish } -> bool
323
+ | () { (E) -> boolish } -> bool
244
324
 
245
325
  # <!--
246
326
  # rdoc-file=enum.c
@@ -260,7 +340,7 @@ module Enumerable[unchecked out Elem] : _Each[Elem]
260
340
  # [].any? # => false
261
341
  #
262
342
  # With argument `pattern` and no block, returns whether for any element
263
- # `element`, `pattern === element`:
343
+ # `element`, <code>pattern === element</code>:
264
344
  #
265
345
  # [nil, false, 0].any?(Integer) # => true
266
346
  # [nil, false, 0].any?(Numeric) # => true
@@ -284,7 +364,7 @@ module Enumerable[unchecked out Elem] : _Each[Elem]
284
364
  #
285
365
  def any?: () -> bool
286
366
  | (_Pattern) -> bool
287
- | () { (Elem) -> boolish } -> bool
367
+ | () { (E) -> boolish } -> bool
288
368
 
289
369
  # <!--
290
370
  # rdoc-file=enum.c
@@ -301,8 +381,8 @@ module Enumerable[unchecked out Elem] : _Each[Elem]
301
381
  #
302
382
  # With no block given, returns an Enumerator.
303
383
  #
304
- def collect: [U] () { (Elem arg0) -> U } -> ::Array[U]
305
- | () -> ::Enumerator[Elem, ::Array[untyped]]
384
+ def collect: [U] () { (E arg0) -> U } -> ::Array[U]
385
+ | () -> ::Enumerator[E, ::Array[untyped]]
306
386
 
307
387
  # <!-- rdoc-file=enum.c -->
308
388
  # Returns an array of flattened objects returned by the block.
@@ -319,8 +399,8 @@ module Enumerable[unchecked out Elem] : _Each[Elem]
319
399
  #
320
400
  # Alias: #collect_concat.
321
401
  #
322
- def collect_concat: [U] () { (Elem) -> (::Array[U] | U) } -> ::Array[U]
323
- | () -> ::Enumerator[Elem, ::Array[untyped]]
402
+ def collect_concat: [U] () { (E) -> (::Array[U] | U) } -> ::Array[U]
403
+ | () -> ::Enumerator[E, ::Array[untyped]]
324
404
 
325
405
  # <!--
326
406
  # rdoc-file=enum.c
@@ -331,7 +411,7 @@ module Enumerable[unchecked out Elem] : _Each[Elem]
331
411
  # a = [nil, 0, nil, 'a', false, nil, false, nil, 'a', nil, 0, nil]
332
412
  # a.compact # => [0, "a", false, false, "a", 0]
333
413
  #
334
- def compact: () -> Array[Elem]
414
+ def compact: () -> Array[E]
335
415
 
336
416
  # <!--
337
417
  # rdoc-file=enum.c
@@ -347,8 +427,8 @@ module Enumerable[unchecked out Elem] : _Each[Elem]
347
427
  # [0, 1, 2].count # => 3
348
428
  # {foo: 0, bar: 1, baz: 2}.count # => 3
349
429
  #
350
- # With argument `object` given, returns the number of elements that are `==` to
351
- # `object`:
430
+ # With argument `object` given, returns the number of elements that are
431
+ # <code>==</code> to `object`:
352
432
  #
353
433
  # [0, 1, 2, 1].count(1) # => 2
354
434
  #
@@ -359,8 +439,8 @@ module Enumerable[unchecked out Elem] : _Each[Elem]
359
439
  # {foo: 0, bar: 1, baz: 2}.count {|key, value| value < 2} # => 2
360
440
  #
361
441
  def count: () -> Integer
362
- | (Elem) -> Integer
363
- | () { (Elem) -> boolish } -> Integer
442
+ | (E) -> Integer
443
+ | () { (E) -> boolish } -> Integer
364
444
 
365
445
  # <!--
366
446
  # rdoc-file=enum.c
@@ -387,8 +467,8 @@ module Enumerable[unchecked out Elem] : _Each[Elem]
387
467
  #
388
468
  # When no block is given, returns an Enumerator.
389
469
  #
390
- def cycle: (?Integer n) { (Elem arg0) -> untyped } -> NilClass
391
- | (?Integer n) -> ::Enumerator[Elem, NilClass]
470
+ def cycle: (?Integer n) { (E arg0) -> untyped } -> NilClass
471
+ | (?Integer n) -> ::Enumerator[E, NilClass]
392
472
 
393
473
  # <!-- rdoc-file=enum.c -->
394
474
  # Returns the first element for which the block returns a truthy value.
@@ -408,8 +488,8 @@ module Enumerable[unchecked out Elem] : _Each[Elem]
408
488
  #
409
489
  # With no block given, returns an Enumerator.
410
490
  #
411
- def detect: (?Proc ifnone) { (Elem) -> boolish } -> Elem?
412
- | (?Proc ifnone) -> ::Enumerator[Elem, Elem?]
491
+ def detect: (?Proc ifnone) { (E) -> boolish } -> E?
492
+ | (?Proc ifnone) -> ::Enumerator[E, E?]
413
493
 
414
494
  # <!--
415
495
  # rdoc-file=enum.c
@@ -428,7 +508,7 @@ module Enumerable[unchecked out Elem] : _Each[Elem]
428
508
  # h = {foo: 0, bar: 1, baz: 2, bat: 3}
429
509
  # h.drop(2) # => [[:baz, 2], [:bat, 3]]
430
510
  #
431
- def drop: (Integer n) -> ::Array[Elem]
511
+ def drop: (Integer n) -> ::Array[E]
432
512
 
433
513
  # <!--
434
514
  # rdoc-file=enum.c
@@ -445,8 +525,19 @@ module Enumerable[unchecked out Elem] : _Each[Elem]
445
525
  #
446
526
  # With no block given, returns an Enumerator.
447
527
  #
448
- def drop_while: () { (Elem) -> boolish } -> ::Array[Elem]
449
- | () -> ::Enumerator[Elem, ::Array[Elem]]
528
+ # e = (1..4).drop_while
529
+ # p e #=> #<Enumerator: 1..4:drop_while>
530
+ # i = e.next; p i; e.feed(i < 3) #=> 1
531
+ # i = e.next; p i; e.feed(i < 3) #=> 2
532
+ # i = e.next; p i; e.feed(i < 3) #=> 3
533
+ # begin
534
+ # e.next
535
+ # rescue StopIteration
536
+ # p $!.result #=> [3, 4]
537
+ # end
538
+ #
539
+ def drop_while: () { (E) -> boolish } -> ::Array[E]
540
+ | () -> ::Enumerator[E, ::Array[E]]
450
541
 
451
542
  # <!--
452
543
  # rdoc-file=enum.c
@@ -467,16 +558,16 @@ module Enumerable[unchecked out Elem] : _Each[Elem]
467
558
  #
468
559
  # With no block given, returns an Enumerator.
469
560
  #
470
- def each_cons: (Integer n) { (::Array[Elem]) -> void } -> self
471
- | (Integer n) -> ::Enumerator[::Array[Elem], self]
561
+ def each_cons: (Integer n) { (::Array[E]) -> void } -> self
562
+ | (Integer n) -> ::Enumerator[::Array[E], self]
472
563
 
473
564
  # <!--
474
565
  # rdoc-file=enum.c
475
566
  # - each_with_index(*args) {|element, i| ..... } -> self
476
567
  # - each_with_index(*args) -> enumerator
477
568
  # -->
478
- # Invoke `self.each` with `*args`. With a block given, the block receives each
479
- # element and its index; returns `self`:
569
+ # Invoke <code>self.each</code> with <code>*args</code>. With a block given, the
570
+ # block receives each element and its index; returns `self`:
480
571
  #
481
572
  # h = {}
482
573
  # (1..4).each_with_index {|element, i| h[element] = i } # => 1..4
@@ -495,8 +586,8 @@ module Enumerable[unchecked out Elem] : _Each[Elem]
495
586
  #
496
587
  # With no block given, returns an Enumerator.
497
588
  #
498
- def each_with_index: () { (Elem, Integer index) -> untyped } -> self
499
- | () -> ::Enumerator[[ Elem, Integer ], self]
589
+ def each_with_index: () { (E, Integer index) -> untyped } -> self
590
+ | () -> ::Enumerator[[ E, Integer ], self]
500
591
 
501
592
  # <!--
502
593
  # rdoc-file=enum.c
@@ -514,18 +605,18 @@ module Enumerable[unchecked out Elem] : _Each[Elem]
514
605
  #
515
606
  # With no block given, returns an Enumerator.
516
607
  #
517
- def each_with_object: [U] (U obj) { (Elem, U obj) -> untyped } -> U
518
- | [U] (U obj) -> ::Enumerator[[ Elem, U ], U]
608
+ def each_with_object: [U] (U obj) { (E, U obj) -> untyped } -> U
609
+ | [U] (U obj) -> ::Enumerator[[ E, U ], U]
519
610
 
520
611
  # <!-- rdoc-file=enum.c -->
521
612
  # Returns an array containing the items in `self`:
522
613
  #
523
614
  # (0..4).to_a # => [0, 1, 2, 3, 4]
524
615
  #
525
- def entries: () -> ::Array[Elem]
616
+ def entries: () -> ::Array[E]
526
617
 
527
618
  def enum_for: (Symbol method, *untyped, **untyped) ?{ (?) -> Integer } -> Enumerator[untyped, untyped]
528
- | () ?{ () -> Integer } -> Enumerator[Elem, self]
619
+ | () ?{ () -> Integer } -> Enumerator[E, self]
529
620
 
530
621
  %a{annotate:rdoc:skip}
531
622
  alias to_enum enum_for
@@ -548,8 +639,8 @@ module Enumerable[unchecked out Elem] : _Each[Elem]
548
639
  #
549
640
  # Related: #reject.
550
641
  #
551
- def find_all: () { (Elem) -> boolish } -> ::Array[Elem]
552
- | () -> ::Enumerator[Elem, ::Array[Elem]]
642
+ def find_all: () { (E) -> boolish } -> ::Array[E]
643
+ | () -> ::Enumerator[E, ::Array[E]]
553
644
 
554
645
  # <!-- rdoc-file=enum.c -->
555
646
  # Returns an array containing elements selected by the block.
@@ -593,7 +684,7 @@ module Enumerable[unchecked out Elem] : _Each[Elem]
593
684
  # `nil` if no such element is found.
594
685
  #
595
686
  # With argument `object` given, returns the index of the first element that is
596
- # `==` `object`:
687
+ # <code>==</code> `object`:
597
688
  #
598
689
  # ['a', 'b', 'c', 'b'].find_index('b') # => 1
599
690
  #
@@ -606,8 +697,8 @@ module Enumerable[unchecked out Elem] : _Each[Elem]
606
697
  # With no argument and no block given, returns an Enumerator.
607
698
  #
608
699
  def find_index: (untyped value) -> Integer?
609
- | () { (Elem) -> boolish } -> Integer?
610
- | () -> ::Enumerator[Elem, Integer?]
700
+ | () { (E) -> boolish } -> Integer?
701
+ | () -> ::Enumerator[E, Integer?]
611
702
 
612
703
  # <!--
613
704
  # rdoc-file=enum.c
@@ -632,8 +723,8 @@ module Enumerable[unchecked out Elem] : _Each[Elem]
632
723
  # {foo: 1, bar: 1, baz: 2}.first(2) # => [[:foo, 1], [:bar, 1]]
633
724
  # [].first(2) # => []
634
725
  #
635
- def first: () -> Elem?
636
- | (_ToInt n) -> ::Array[Elem]
726
+ def first: () -> E?
727
+ | (_ToInt n) -> ::Array[E]
637
728
 
638
729
  # <!--
639
730
  # rdoc-file=enum.c
@@ -644,7 +735,7 @@ module Enumerable[unchecked out Elem] : _Each[Elem]
644
735
  # pattern.
645
736
  #
646
737
  # With no block given, returns an array containing each element for which
647
- # `pattern === element` is `true`:
738
+ # <code>pattern === element</code> is `true`:
648
739
  #
649
740
  # a = ['foo', 'bar', 'car', 'moo']
650
741
  # a.grep(/ar/) # => ["bar", "car"]
@@ -659,19 +750,19 @@ module Enumerable[unchecked out Elem] : _Each[Elem]
659
750
  #
660
751
  # Related: #grep_v.
661
752
  #
662
- def grep: (untyped arg0) -> ::Array[Elem]
663
- | [U] (untyped arg0) { (Elem arg0) -> U } -> ::Array[U]
753
+ def grep: (untyped arg0) -> ::Array[E]
754
+ | [U] (untyped arg0) { (E arg0) -> U } -> ::Array[U]
664
755
 
665
756
  # <!--
666
757
  # rdoc-file=enum.c
667
758
  # - grep_v(pattern) -> array
668
759
  # - grep_v(pattern) {|element| ... } -> array
669
760
  # -->
670
- # Returns an array of objects based on elements of `self` that *don't* match the
671
- # given pattern.
761
+ # Returns an array of objects based on elements of `self` that <em>don't</em>
762
+ # match the given pattern.
672
763
  #
673
764
  # With no block given, returns an array containing each element for which
674
- # `pattern === element` is `false`:
765
+ # <code>pattern === element</code> is `false`:
675
766
  #
676
767
  # a = ['foo', 'bar', 'car', 'moo']
677
768
  # a.grep_v(/ar/) # => ["foo", "moo"]
@@ -686,8 +777,8 @@ module Enumerable[unchecked out Elem] : _Each[Elem]
686
777
  #
687
778
  # Related: #grep.
688
779
  #
689
- def grep_v: (untyped) -> ::Array[Elem]
690
- | [U] (untyped) { (Elem) -> U } -> ::Array[U]
780
+ def grep_v: (untyped) -> ::Array[E]
781
+ | [U] (untyped) { (E) -> U } -> ::Array[U]
691
782
 
692
783
  # <!--
693
784
  # rdoc-file=enum.c
@@ -710,11 +801,11 @@ module Enumerable[unchecked out Elem] : _Each[Elem]
710
801
  #
711
802
  # With no block given, returns an Enumerator.
712
803
  #
713
- def group_by: [U] () { (Elem arg0) -> U } -> ::Hash[U, ::Array[Elem]]
714
- | () -> ::Enumerator[Elem, ::Array[Elem]]
804
+ def group_by: [U] () { (E arg0) -> U } -> ::Hash[U, ::Array[E]]
805
+ | () -> ::Enumerator[E, ::Array[E]]
715
806
 
716
807
  # <!-- rdoc-file=enum.c -->
717
- # Returns whether for any element `object == element`:
808
+ # Returns whether for any element <code>object == element</code>:
718
809
  #
719
810
  # (1..4).include?(2) # => true
720
811
  # (1..4).include?(5) # => false
@@ -725,7 +816,7 @@ module Enumerable[unchecked out Elem] : _Each[Elem]
725
816
  # {foo: 0, bar: 1, baz: 2}.include?('foo') # => false
726
817
  # {foo: 0, bar: 1, baz: 2}.include?(0) # => false
727
818
  #
728
- def include?: (Elem arg0) -> bool
819
+ def include?: (top arg0) -> bool
729
820
 
730
821
  # <!--
731
822
  # rdoc-file=enum.c
@@ -772,13 +863,13 @@ module Enumerable[unchecked out Elem] : _Each[Elem]
772
863
  # product #=> 24
773
864
  #
774
865
  # When this runs, the block is first called with `1` (the initial value) and `2`
775
- # (the first element of the array). The block returns `1*2`, so on the next
776
- # iteration the block is called with `2` (the previous result) and `3`. The
777
- # block returns `6`, and is called one last time with `6` and `4`. The result of
778
- # the block, `24` becomes the value returned by `inject`. This code returns the
779
- # product of the elements in the enumerable.
866
+ # (the first element of the array). The block returns <code>1*2</code>, so on
867
+ # the next iteration the block is called with `2` (the previous result) and `3`.
868
+ # The block returns `6`, and is called one last time with `6` and `4`. The
869
+ # result of the block, `24` becomes the value returned by `inject`. This code
870
+ # returns the product of the elements in the enumerable.
780
871
  #
781
- # **First Shortcut: Default Initial value**
872
+ # <strong>First Shortcut: Default Initial value</strong>
782
873
  #
783
874
  # In the case of the previous example, the initial value, `1`, wasn't really
784
875
  # necessary: the calculation of the product of a list of numbers is
@@ -815,7 +906,7 @@ module Enumerable[unchecked out Elem] : _Each[Elem]
815
906
  # Note that the last line of the block is just the word `counts`. This ensures
816
907
  # the return value of the block is the result that's being calculated.
817
908
  #
818
- # **Second Shortcut: a Reducer function**
909
+ # <strong>Second Shortcut: a Reducer function</strong>
819
910
  #
820
911
  # A *reducer function* is a function that takes a partial result and the next
821
912
  # value, returning the next partial result. The block that is given to `inject`
@@ -860,11 +951,11 @@ module Enumerable[unchecked out Elem] : _Each[Elem]
860
951
  # position = "nnneesw".chars.reduce(Turtle.new, :move)
861
952
  # position #=>> #<Turtle:0x00000001052f4698 @y=2, @x=1>
862
953
  #
863
- # **Third Shortcut: Reducer With no Initial Value**
954
+ # <strong>Third Shortcut: Reducer With no Initial Value</strong>
864
955
  #
865
956
  # If your reducer returns a value that it can accept as a parameter, then you
866
- # don't have to pass in an initial value. Here `:*` is the name of the *times*
867
- # function:
957
+ # don't have to pass in an initial value. Here <code>:*</code> is the name of
958
+ # the *times* function:
868
959
  #
869
960
  # product = [ 2, 3, 4 ].inject(:*)
870
961
  # product # => 24
@@ -881,8 +972,8 @@ module Enumerable[unchecked out Elem] : _Each[Elem]
881
972
  #
882
973
  def inject: (untyped init, Symbol method) -> untyped
883
974
  | (Symbol method) -> untyped
884
- | [A] (A initial) { (A, Elem) -> A } -> A
885
- | () { (Elem, Elem) -> Elem } -> Elem
975
+ | [A] (A initial) { (A, E) -> A } -> A
976
+ | () { (E, E) -> E } -> E
886
977
 
887
978
  # <!--
888
979
  # rdoc-file=enum.c
@@ -895,7 +986,7 @@ module Enumerable[unchecked out Elem] : _Each[Elem]
895
986
  # The ordering of equal elements is indeterminate and may be unstable.
896
987
  #
897
988
  # With no argument and no block, returns the maximum element, using the
898
- # elements' own method `#<=>` for comparison:
989
+ # elements' own method <code>#<=></code> for comparison:
899
990
  #
900
991
  # (1..4).max # => 4
901
992
  # (-4..-1).max # => -1
@@ -915,9 +1006,9 @@ module Enumerable[unchecked out Elem] : _Each[Elem]
915
1006
  # With a block given, the block determines the maximum elements. The block is
916
1007
  # called with two elements `a` and `b`, and must return:
917
1008
  #
918
- # * A negative integer if `a < b`.
919
- # * Zero if `a == b`.
920
- # * A positive integer if `a > b`.
1009
+ # * A negative integer if <code>a < b</code>.
1010
+ # * Zero if <code>a == b</code>.
1011
+ # * A positive integer if <code>a > b</code>.
921
1012
  #
922
1013
  # With a block given and no argument, returns the maximum element as determined
923
1014
  # by the block:
@@ -939,10 +1030,10 @@ module Enumerable[unchecked out Elem] : _Each[Elem]
939
1030
  #
940
1031
  # Related: #min, #minmax, #max_by.
941
1032
  #
942
- def max: () -> Elem?
943
- | () { (Elem arg0, Elem arg1) -> Integer } -> Elem?
944
- | (Integer arg0) -> ::Array[Elem]
945
- | (Integer arg0) { (Elem arg0, Elem arg1) -> Integer } -> ::Array[Elem]
1033
+ def max: () -> E?
1034
+ | () { (E arg0, E arg1) -> Integer } -> E?
1035
+ | (Integer arg0) -> ::Array[E]
1036
+ | (Integer arg0) { (E arg0, E arg1) -> Integer } -> ::Array[E]
946
1037
 
947
1038
  # <!--
948
1039
  # rdoc-file=enum.c
@@ -977,10 +1068,10 @@ module Enumerable[unchecked out Elem] : _Each[Elem]
977
1068
  #
978
1069
  # Related: #max, #minmax, #min_by.
979
1070
  #
980
- def max_by: () -> ::Enumerator[Elem, Elem?]
981
- | () { (Elem arg0) -> (Comparable | ::Array[untyped]) } -> Elem?
982
- | (Integer arg0) -> ::Enumerator[Elem, ::Array[Elem]]
983
- | (Integer arg0) { (Elem arg0) -> (Comparable | ::Array[untyped]) } -> ::Array[Elem]
1071
+ def max_by: () -> ::Enumerator[E, E?]
1072
+ | () { (E arg0) -> (Comparable | ::Array[untyped]) } -> E?
1073
+ | (Integer arg0) -> ::Enumerator[E, ::Array[E]]
1074
+ | (Integer arg0) { (E arg0) -> (Comparable | ::Array[untyped]) } -> ::Array[E]
984
1075
 
985
1076
  # <!--
986
1077
  # rdoc-file=enum.c
@@ -993,7 +1084,7 @@ module Enumerable[unchecked out Elem] : _Each[Elem]
993
1084
  # The ordering of equal elements is indeterminate and may be unstable.
994
1085
  #
995
1086
  # With no argument and no block, returns the minimum element, using the
996
- # elements' own method `#<=>` for comparison:
1087
+ # elements' own method <code>#<=></code> for comparison:
997
1088
  #
998
1089
  # (1..4).min # => 1
999
1090
  # (-4..-1).min # => -4
@@ -1013,9 +1104,9 @@ module Enumerable[unchecked out Elem] : _Each[Elem]
1013
1104
  # With a block given, the block determines the minimum elements. The block is
1014
1105
  # called with two elements `a` and `b`, and must return:
1015
1106
  #
1016
- # * A negative integer if `a < b`.
1017
- # * Zero if `a == b`.
1018
- # * A positive integer if `a > b`.
1107
+ # * A negative integer if <code>a < b</code>.
1108
+ # * Zero if <code>a == b</code>.
1109
+ # * A positive integer if <code>a > b</code>.
1019
1110
  #
1020
1111
  # With a block given and no argument, returns the minimum element as determined
1021
1112
  # by the block:
@@ -1037,10 +1128,10 @@ module Enumerable[unchecked out Elem] : _Each[Elem]
1037
1128
  #
1038
1129
  # Related: #min_by, #minmax, #max.
1039
1130
  #
1040
- def min: () -> Elem?
1041
- | () { (Elem arg0, Elem arg1) -> Integer } -> Elem?
1042
- | (Integer arg0) -> ::Array[Elem]
1043
- | (Integer arg0) { (Elem arg0, Elem arg1) -> Integer } -> ::Array[Elem]
1131
+ def min: () -> E?
1132
+ | () { (E arg0, E arg1) -> Integer } -> E?
1133
+ | (Integer arg0) -> ::Array[E]
1134
+ | (Integer arg0) { (E arg0, E arg1) -> Integer } -> ::Array[E]
1044
1135
 
1045
1136
  # <!--
1046
1137
  # rdoc-file=enum.c
@@ -1075,10 +1166,10 @@ module Enumerable[unchecked out Elem] : _Each[Elem]
1075
1166
  #
1076
1167
  # Related: #min, #minmax, #max_by.
1077
1168
  #
1078
- def min_by: () -> ::Enumerator[Elem, Elem?]
1079
- | () { (Elem arg0) -> (Comparable | ::Array[untyped]) } -> Elem?
1080
- | (Integer arg0) -> ::Enumerator[Elem, ::Array[Elem]]
1081
- | (Integer arg0) { (Elem arg0) -> (Comparable | ::Array[untyped]) } -> ::Array[Elem]
1169
+ def min_by: () -> ::Enumerator[E, E?]
1170
+ | () { (E arg0) -> (Comparable | ::Array[untyped]) } -> E?
1171
+ | (Integer arg0) -> ::Enumerator[E, ::Array[E]]
1172
+ | (Integer arg0) { (E arg0) -> (Comparable | ::Array[untyped]) } -> ::Array[E]
1082
1173
 
1083
1174
  # <!--
1084
1175
  # rdoc-file=enum.c
@@ -1090,7 +1181,7 @@ module Enumerable[unchecked out Elem] : _Each[Elem]
1090
1181
  # indeterminate and may be unstable.
1091
1182
  #
1092
1183
  # With no argument and no block, returns the minimum and maximum elements, using
1093
- # the elements' own method `#<=>` for comparison:
1184
+ # the elements' own method <code>#<=></code> for comparison:
1094
1185
  #
1095
1186
  # (1..4).minmax # => [1, 4]
1096
1187
  # (-4..-1).minmax # => [-4, -1]
@@ -1109,8 +1200,8 @@ module Enumerable[unchecked out Elem] : _Each[Elem]
1109
1200
  #
1110
1201
  # Related: #min, #max, #minmax_by.
1111
1202
  #
1112
- def minmax: () -> [ Elem?, Elem? ]
1113
- | () { (Elem arg0, Elem arg1) -> Integer } -> [ Elem?, Elem? ]
1203
+ def minmax: () -> [ E?, E? ]
1204
+ | () { (E arg0, E arg1) -> Integer } -> [ E?, E? ]
1114
1205
 
1115
1206
  # <!--
1116
1207
  # rdoc-file=enum.c
@@ -1133,8 +1224,8 @@ module Enumerable[unchecked out Elem] : _Each[Elem]
1133
1224
  #
1134
1225
  # Related: #max_by, #minmax, #min_by.
1135
1226
  #
1136
- def minmax_by: () -> [ Elem?, Elem? ]
1137
- | () { (Elem arg0) -> (Comparable | ::Array[untyped]) } -> [ Elem?, Elem? ]
1227
+ def minmax_by: () -> [ E?, E? ]
1228
+ | () { (E arg0) -> (Comparable | ::Array[untyped]) } -> [ E?, E? ]
1138
1229
 
1139
1230
  # <!--
1140
1231
  # rdoc-file=enum.c
@@ -1153,7 +1244,7 @@ module Enumerable[unchecked out Elem] : _Each[Elem]
1153
1244
  # [].none? # => true
1154
1245
  #
1155
1246
  # With argument `pattern` and no block, returns whether for no element
1156
- # `element`, `pattern === element`:
1247
+ # `element`, <code>pattern === element</code>:
1157
1248
  #
1158
1249
  # [nil, false, 1.1].none?(Integer) # => true
1159
1250
  # %w[bar baz bat bam].none?(/m/) # => false
@@ -1175,7 +1266,7 @@ module Enumerable[unchecked out Elem] : _Each[Elem]
1175
1266
  #
1176
1267
  def none?: () -> bool
1177
1268
  | (_Pattern) -> bool
1178
- | () { (Elem) -> boolish } -> bool
1269
+ | () { (E) -> boolish } -> bool
1179
1270
 
1180
1271
  # <!--
1181
1272
  # rdoc-file=enum.c
@@ -1195,7 +1286,7 @@ module Enumerable[unchecked out Elem] : _Each[Elem]
1195
1286
  # [].one? # => false
1196
1287
  #
1197
1288
  # With argument `pattern` and no block, returns whether for exactly one element
1198
- # `element`, `pattern === element`:
1289
+ # `element`, <code>pattern === element</code>:
1199
1290
  #
1200
1291
  # [nil, false, 0].one?(Integer) # => true
1201
1292
  # [nil, false, 0].one?(Numeric) # => true
@@ -1219,7 +1310,7 @@ module Enumerable[unchecked out Elem] : _Each[Elem]
1219
1310
  #
1220
1311
  def one?: () -> bool
1221
1312
  | (_Pattern) -> bool
1222
- | () { (Elem) -> boolish } -> bool
1313
+ | () { (E) -> boolish } -> bool
1223
1314
 
1224
1315
  # <!--
1225
1316
  # rdoc-file=enum.c
@@ -1248,8 +1339,8 @@ module Enumerable[unchecked out Elem] : _Each[Elem]
1248
1339
  #
1249
1340
  # Related: Enumerable#group_by.
1250
1341
  #
1251
- def partition: () { (Elem) -> boolish } -> [ ::Array[Elem], ::Array[Elem] ]
1252
- | () -> ::Enumerator[Elem, [ ::Array[Elem], ::Array[Elem] ]]
1342
+ def partition: () { (E) -> boolish } -> [ ::Array[E], ::Array[E] ]
1343
+ | () -> ::Enumerator[E, [ ::Array[E], ::Array[E] ]]
1253
1344
 
1254
1345
  # <!--
1255
1346
  # rdoc-file=enum.c
@@ -1268,8 +1359,8 @@ module Enumerable[unchecked out Elem] : _Each[Elem]
1268
1359
  #
1269
1360
  # Related: #select.
1270
1361
  #
1271
- def reject: () { (Elem) -> boolish } -> ::Array[Elem]
1272
- | () -> ::Enumerator[Elem, ::Array[Elem]]
1362
+ def reject: () { (E) -> boolish } -> ::Array[E]
1363
+ | () -> ::Enumerator[E, ::Array[E]]
1273
1364
 
1274
1365
  # <!--
1275
1366
  # rdoc-file=enum.c
@@ -1295,8 +1386,8 @@ module Enumerable[unchecked out Elem] : _Each[Elem]
1295
1386
  #
1296
1387
  # With no block given, returns an Enumerator.
1297
1388
  #
1298
- def reverse_each: () { (Elem arg0) -> untyped } -> void
1299
- | () -> ::Enumerator[Elem]
1389
+ def reverse_each: () { (E arg0) -> untyped } -> void
1390
+ | () -> ::Enumerator[E]
1300
1391
 
1301
1392
  # <!--
1302
1393
  # rdoc-file=enum.c
@@ -1306,7 +1397,8 @@ module Enumerable[unchecked out Elem] : _Each[Elem]
1306
1397
  # Returns an array containing the sorted elements of `self`. The ordering of
1307
1398
  # equal elements is indeterminate and may be unstable.
1308
1399
  #
1309
- # With no block given, the sort compares using the elements' own method `#<=>`:
1400
+ # With no block given, the sort compares using the elements' own method
1401
+ # <code>#<=></code>:
1310
1402
  #
1311
1403
  # %w[b c a d].sort # => ["a", "b", "c", "d"]
1312
1404
  # {foo: 0, bar: 1, baz: 2}.sort # => [[:bar, 1], [:baz, 2], [:foo, 0]]
@@ -1314,9 +1406,9 @@ module Enumerable[unchecked out Elem] : _Each[Elem]
1314
1406
  # With a block given, comparisons in the block determine the ordering. The block
1315
1407
  # is called with two elements `a` and `b`, and must return:
1316
1408
  #
1317
- # * A negative integer if `a < b`.
1318
- # * Zero if `a == b`.
1319
- # * A positive integer if `a > b`.
1409
+ # * A negative integer if <code>a < b</code>.
1410
+ # * Zero if <code>a == b</code>.
1411
+ # * A positive integer if <code>a > b</code>.
1320
1412
  #
1321
1413
  # Examples:
1322
1414
  #
@@ -1328,8 +1420,8 @@ module Enumerable[unchecked out Elem] : _Each[Elem]
1328
1420
  # See also #sort_by. It implements a Schwartzian transform which is useful when
1329
1421
  # key computation or comparison is expensive.
1330
1422
  #
1331
- def sort: () -> ::Array[Elem]
1332
- | () { (Elem arg0, Elem arg1) -> Integer } -> ::Array[Elem]
1423
+ def sort: () -> ::Array[E]
1424
+ | () { (E arg0, E arg1) -> Integer } -> ::Array[E]
1333
1425
 
1334
1426
  # <!--
1335
1427
  # rdoc-file=enum.c
@@ -1364,7 +1456,7 @@ module Enumerable[unchecked out Elem] : _Each[Elem]
1364
1456
  # b.report("Sort by") { a.sort_by { |a| a } }
1365
1457
  # end
1366
1458
  #
1367
- # *produces:*
1459
+ # <em>produces:</em>
1368
1460
  #
1369
1461
  # user system total real
1370
1462
  # Sort 0.180000 0.000000 0.180000 ( 0.175469)
@@ -1409,8 +1501,8 @@ module Enumerable[unchecked out Elem] : _Each[Elem]
1409
1501
  #
1410
1502
  # ary.sort_by { ... }.reverse!
1411
1503
  #
1412
- def sort_by: () { (Elem arg0) -> (Comparable | ::Array[untyped]) } -> ::Array[Elem]
1413
- | () -> ::Enumerator[Elem, ::Array[Elem]]
1504
+ def sort_by: () { (E arg0) -> (Comparable | ::Array[untyped]) } -> ::Array[E]
1505
+ | () -> ::Enumerator[E, ::Array[E]]
1414
1506
 
1415
1507
  # <!--
1416
1508
  # rdoc-file=enum.c
@@ -1425,7 +1517,7 @@ module Enumerable[unchecked out Elem] : _Each[Elem]
1425
1517
  # h = {foo: 0, bar: 1, baz: 2, bat: 3}
1426
1518
  # h.take(2) # => [[:foo, 0], [:bar, 1]]
1427
1519
  #
1428
- def take: (Integer n) -> ::Array[Elem]
1520
+ def take: (Integer n) -> ::Array[E]
1429
1521
 
1430
1522
  # <!--
1431
1523
  # rdoc-file=enum.c
@@ -1442,8 +1534,8 @@ module Enumerable[unchecked out Elem] : _Each[Elem]
1442
1534
  #
1443
1535
  # With no block given, returns an Enumerator.
1444
1536
  #
1445
- def take_while: () { (Elem) -> boolish } -> ::Array[Elem]
1446
- | () -> ::Enumerator[Elem, ::Array[Elem]]
1537
+ def take_while: () { (E) -> boolish } -> ::Array[E]
1538
+ | () -> ::Enumerator[E, ::Array[E]]
1447
1539
 
1448
1540
  # <!--
1449
1541
  # rdoc-file=enum.c
@@ -1465,7 +1557,7 @@ module Enumerable[unchecked out Elem] : _Each[Elem]
1465
1557
  # block is not passed.
1466
1558
  #
1467
1559
  def to_h: () -> ::Hash[untyped, untyped]
1468
- | [T, U] () { (Elem) -> [ T, U ] } -> ::Hash[T, U]
1560
+ | [T, U] () { (E) -> [ T, U ] } -> ::Hash[T, U]
1469
1561
 
1470
1562
  # <!--
1471
1563
  # rdoc-file=enum.c
@@ -1486,8 +1578,8 @@ module Enumerable[unchecked out Elem] : _Each[Elem]
1486
1578
  #
1487
1579
  # With no block given, returns an Enumerator.
1488
1580
  #
1489
- def each_slice: (Integer n) { (::Array[Elem]) -> void } -> self
1490
- | (Integer n) -> ::Enumerator[::Array[Elem], self]
1581
+ def each_slice: (Integer n) { (::Array[E]) -> void } -> self
1582
+ | (Integer n) -> ::Enumerator[::Array[E], self]
1491
1583
 
1492
1584
  interface _NotFound[T]
1493
1585
  def call: () -> T
@@ -1515,10 +1607,10 @@ module Enumerable[unchecked out Elem] : _Each[Elem]
1515
1607
  #
1516
1608
  # With no block given, returns an Enumerator.
1517
1609
  #
1518
- def find: () { (Elem) -> boolish } -> Elem?
1519
- | () -> ::Enumerator[Elem, Elem?]
1520
- | [T] (_NotFound[T] ifnone) { (Elem) -> boolish } -> (Elem | T)
1521
- | [T] (_NotFound[T] ifnone) -> ::Enumerator[Elem, Elem | T]
1610
+ def find: () { (E) -> boolish } -> E?
1611
+ | () -> ::Enumerator[E, E?]
1612
+ | [T] (_NotFound[T] ifnone) { (E) -> boolish } -> (E | T)
1613
+ | [T] (_NotFound[T] ifnone) -> ::Enumerator[E, E | T]
1522
1614
 
1523
1615
  # <!--
1524
1616
  # rdoc-file=enum.c
@@ -1539,8 +1631,8 @@ module Enumerable[unchecked out Elem] : _Each[Elem]
1539
1631
  #
1540
1632
  # Alias: #collect_concat.
1541
1633
  #
1542
- def flat_map: [U] () { (Elem) -> (Array[U] | U) } -> Array[U]
1543
- | () -> ::Enumerator[Elem, Array[untyped]]
1634
+ def flat_map: [U] () { (E) -> (Array[U] | U) } -> Array[U]
1635
+ | () -> ::Enumerator[E, Array[untyped]]
1544
1636
 
1545
1637
  # <!-- rdoc-file=enum.c -->
1546
1638
  # Returns an array of objects returned by the block.
@@ -1553,14 +1645,14 @@ module Enumerable[unchecked out Elem] : _Each[Elem]
1553
1645
  #
1554
1646
  # With no block given, returns an Enumerator.
1555
1647
  #
1556
- def map: [U] () { (Elem arg0) -> U } -> ::Array[U]
1557
- | () -> ::Enumerator[Elem, ::Array[untyped]]
1648
+ def map: [U] () { (E arg0) -> U } -> ::Array[U]
1649
+ | () -> ::Enumerator[E, ::Array[untyped]]
1558
1650
 
1559
1651
  # <!--
1560
1652
  # rdoc-file=enum.c
1561
1653
  # - include?(object) -> true or false
1562
1654
  # -->
1563
- # Returns whether for any element `object == element`:
1655
+ # Returns whether for any element <code>object == element</code>:
1564
1656
  #
1565
1657
  # (1..4).include?(2) # => true
1566
1658
  # (1..4).include?(5) # => false
@@ -1571,7 +1663,7 @@ module Enumerable[unchecked out Elem] : _Each[Elem]
1571
1663
  # {foo: 0, bar: 1, baz: 2}.include?('foo') # => false
1572
1664
  # {foo: 0, bar: 1, baz: 2}.include?(0) # => false
1573
1665
  #
1574
- def member?: (Elem arg0) -> bool
1666
+ def member?: (top arg0) -> bool
1575
1667
 
1576
1668
  # <!-- rdoc-file=enum.c -->
1577
1669
  # Returns the result of applying a reducer to an initial value and the first
@@ -1612,13 +1704,13 @@ module Enumerable[unchecked out Elem] : _Each[Elem]
1612
1704
  # product #=> 24
1613
1705
  #
1614
1706
  # When this runs, the block is first called with `1` (the initial value) and `2`
1615
- # (the first element of the array). The block returns `1*2`, so on the next
1616
- # iteration the block is called with `2` (the previous result) and `3`. The
1617
- # block returns `6`, and is called one last time with `6` and `4`. The result of
1618
- # the block, `24` becomes the value returned by `inject`. This code returns the
1619
- # product of the elements in the enumerable.
1707
+ # (the first element of the array). The block returns <code>1*2</code>, so on
1708
+ # the next iteration the block is called with `2` (the previous result) and `3`.
1709
+ # The block returns `6`, and is called one last time with `6` and `4`. The
1710
+ # result of the block, `24` becomes the value returned by `inject`. This code
1711
+ # returns the product of the elements in the enumerable.
1620
1712
  #
1621
- # **First Shortcut: Default Initial value**
1713
+ # <strong>First Shortcut: Default Initial value</strong>
1622
1714
  #
1623
1715
  # In the case of the previous example, the initial value, `1`, wasn't really
1624
1716
  # necessary: the calculation of the product of a list of numbers is
@@ -1655,7 +1747,7 @@ module Enumerable[unchecked out Elem] : _Each[Elem]
1655
1747
  # Note that the last line of the block is just the word `counts`. This ensures
1656
1748
  # the return value of the block is the result that's being calculated.
1657
1749
  #
1658
- # **Second Shortcut: a Reducer function**
1750
+ # <strong>Second Shortcut: a Reducer function</strong>
1659
1751
  #
1660
1752
  # A *reducer function* is a function that takes a partial result and the next
1661
1753
  # value, returning the next partial result. The block that is given to `inject`
@@ -1700,11 +1792,11 @@ module Enumerable[unchecked out Elem] : _Each[Elem]
1700
1792
  # position = "nnneesw".chars.reduce(Turtle.new, :move)
1701
1793
  # position #=>> #<Turtle:0x00000001052f4698 @y=2, @x=1>
1702
1794
  #
1703
- # **Third Shortcut: Reducer With no Initial Value**
1795
+ # <strong>Third Shortcut: Reducer With no Initial Value</strong>
1704
1796
  #
1705
1797
  # If your reducer returns a value that it can accept as a parameter, then you
1706
- # don't have to pass in an initial value. Here `:*` is the name of the *times*
1707
- # function:
1798
+ # don't have to pass in an initial value. Here <code>:*</code> is the name of
1799
+ # the *times* function:
1708
1800
  #
1709
1801
  # product = [ 2, 3, 4 ].inject(:*)
1710
1802
  # product # => 24
@@ -1729,7 +1821,7 @@ module Enumerable[unchecked out Elem] : _Each[Elem]
1729
1821
  #
1730
1822
  # (0..4).to_a # => [0, 1, 2, 3, 4]
1731
1823
  #
1732
- def to_a: () -> ::Array[Elem]
1824
+ def to_a: () -> ::Array[E]
1733
1825
 
1734
1826
  # <!--
1735
1827
  # rdoc-file=enumerator.c
@@ -1759,7 +1851,7 @@ module Enumerable[unchecked out Elem] : _Each[Elem]
1759
1851
  # # show pythagorean triples less than 100
1760
1852
  # p pythagorean_triples.take_while { |*, z| z < 100 }.force
1761
1853
  #
1762
- def lazy: () -> Enumerator::Lazy[Elem]
1854
+ def lazy: () -> Enumerator::Lazy[E]
1763
1855
 
1764
1856
  # <!--
1765
1857
  # rdoc-file=enum.c
@@ -1767,7 +1859,7 @@ module Enumerable[unchecked out Elem] : _Each[Elem]
1767
1859
  # - uniq {|element| ... } -> array
1768
1860
  # -->
1769
1861
  # With no block, returns a new array containing only unique elements; the array
1770
- # has no two elements `e0` and `e1` such that `e0.eql?(e1)`:
1862
+ # has no two elements `e0` and `e1` such that <code>e0.eql?(e1)</code>:
1771
1863
  #
1772
1864
  # %w[a b c c b a a b c].uniq # => ["a", "b", "c"]
1773
1865
  # [0, 1, 2, 2, 1, 0, 0, 1, 2].uniq # => [0, 1, 2]
@@ -1780,8 +1872,8 @@ module Enumerable[unchecked out Elem] : _Each[Elem]
1780
1872
  # a = %w[a b c d e e d c b a a b c d e]
1781
1873
  # a.uniq {|c| c < 'c' } # => ["a", "c"]
1782
1874
  #
1783
- def uniq: () -> ::Array[Elem]
1784
- | () { (Elem item) -> untyped } -> ::Array[Elem]
1875
+ def uniq: () -> ::Array[E]
1876
+ | () { (E item) -> untyped } -> ::Array[E]
1785
1877
 
1786
1878
  # <!--
1787
1879
  # rdoc-file=enum.c
@@ -1794,12 +1886,12 @@ module Enumerable[unchecked out Elem] : _Each[Elem]
1794
1886
  # (1..100).sum(1) # => 5051
1795
1887
  # ('a'..'d').sum('foo') # => "fooabcd"
1796
1888
  #
1797
- # Generally, the sum is computed using methods `+` and `each`; for performance
1798
- # optimizations, those methods may not be used, and so any redefinition of those
1799
- # methods may not have effect here.
1889
+ # Generally, the sum is computed using methods <code>+</code> and `each`; for
1890
+ # performance optimizations, those methods may not be used, and so any
1891
+ # redefinition of those methods may not have effect here.
1800
1892
  #
1801
1893
  # One such optimization: When possible, computes using Gauss's summation formula
1802
- # *n(n+1)/2*:
1894
+ # <em>n(n+1)/2</em>:
1803
1895
  #
1804
1896
  # 100 * (100 + 1) / 2 # => 5050
1805
1897
  #
@@ -1812,10 +1904,10 @@ module Enumerable[unchecked out Elem] : _Each[Elem]
1812
1904
  # h.sum {|key, value| value.odd? ? value : 0 } # => 9
1813
1905
  # ('a'..'f').sum('x') {|c| c < 'd' ? c : '' } # => "xabc"
1814
1906
  #
1815
- def sum: () -> (Elem | Integer)
1816
- | [T] () { (Elem arg0) -> T } -> (Integer | T)
1817
- | [T] (?T arg0) -> (Elem | T)
1818
- | [U] (?U arg0) { (Elem arg0) -> U } -> U
1907
+ def sum: () -> (E | Integer)
1908
+ | [T] () { (E arg0) -> T } -> (Integer | T)
1909
+ | [T] (?T arg0) -> (E | T)
1910
+ | [U] (?U arg0) { (E arg0) -> U } -> U
1819
1911
 
1820
1912
  # <!--
1821
1913
  # rdoc-file=enum.c
@@ -1832,8 +1924,8 @@ module Enumerable[unchecked out Elem] : _Each[Elem]
1832
1924
  #
1833
1925
  # When no block given, returns an Enumerator.
1834
1926
  #
1835
- def filter_map: [U] () { (Elem elem) -> (nil | false | U) } -> ::Array[U]
1836
- | () -> ::Enumerator[Elem, ::Array[untyped]]
1927
+ def filter_map: [U] () { (E elem) -> (nil | false | U) } -> ::Array[U]
1928
+ | () -> ::Enumerator[E, ::Array[untyped]]
1837
1929
 
1838
1930
  # <!--
1839
1931
  # rdoc-file=enumerator.c
@@ -1845,7 +1937,7 @@ module Enumerable[unchecked out Elem] : _Each[Elem]
1845
1937
  # e = (1..3).chain([4, 5])
1846
1938
  # e.to_a #=> [1, 2, 3, 4, 5]
1847
1939
  #
1848
- def chain: [Elem2] (*_Each[Elem2] enumerables) -> ::Enumerator::Chain[Elem | Elem2]
1940
+ def chain: [Elem2] (*_Each[Elem2] enumerables) -> ::Enumerator::Chain[E | Elem2]
1849
1941
 
1850
1942
  # <!--
1851
1943
  # rdoc-file=enum.c
@@ -1891,7 +1983,7 @@ module Enumerable[unchecked out Elem] : _Each[Elem]
1891
1983
  # {foo: 'a', bar: 'b'}.tally(h) # => {[:foo, "a"]=>2, [:bar, "b"]=>2, [:foo, "c"]=>1, [:bar, "d"]=>1}
1892
1984
  # {foo: 'c', bar: 'd'}.tally(h) # => {[:foo, "a"]=>2, [:bar, "b"]=>2, [:foo, "c"]=>2, [:bar, "d"]=>2}
1893
1985
  #
1894
- def tally: (?Hash[Elem, Integer] hash) -> ::Hash[Elem, Integer]
1986
+ def tally: (?Hash[E, Integer] hash) -> ::Hash[E, Integer]
1895
1987
 
1896
1988
  # <!--
1897
1989
  # rdoc-file=enum.c
@@ -1929,8 +2021,8 @@ module Enumerable[unchecked out Elem] : _Each[Elem]
1929
2021
  #
1930
2022
  # With no block given, returns an Enumerator.
1931
2023
  #
1932
- def each_entry: () -> ::Enumerator[Elem, self]
1933
- | () { (Elem arg0) -> untyped } -> self
2024
+ def each_entry: () -> ::Enumerator[E, self]
2025
+ | () { (E arg0) -> untyped } -> self
1934
2026
 
1935
2027
  # <!--
1936
2028
  # rdoc-file=enum.c
@@ -1938,8 +2030,8 @@ module Enumerable[unchecked out Elem] : _Each[Elem]
1938
2030
  # - zip(*other_enums) {|array| ... } -> nil
1939
2031
  # -->
1940
2032
  # With no block given, returns a new array `new_array` of size self.size whose
1941
- # elements are arrays. Each nested array `new_array[n]` is of size
1942
- # `other_enums.size+1`, and contains:
2033
+ # elements are arrays. Each nested array <code>new_array[n]</code> is of size
2034
+ # <code>other_enums.size+1</code>, and contains:
1943
2035
  #
1944
2036
  # * The `n`-th element of self.
1945
2037
  # * The `n`-th element of each of the `other_enums`.
@@ -1963,8 +2055,8 @@ module Enumerable[unchecked out Elem] : _Each[Elem]
1963
2055
  # # [[:baz, 2], [:gaz, 5], [:haz, 8]]
1964
2056
  # # ]
1965
2057
  #
1966
- # If any enumerable in other_enums is smaller than self, fills to `self.size`
1967
- # with `nil`:
2058
+ # If any enumerable in other_enums is smaller than self, fills to
2059
+ # <code>self.size</code> with `nil`:
1968
2060
  #
1969
2061
  # a = [:a0, :a1, :a2, :a3]
1970
2062
  # b = [:b0, :b1, :b2]
@@ -1996,9 +2088,9 @@ module Enumerable[unchecked out Elem] : _Each[Elem]
1996
2088
  # [:a2, :b2, :c2]
1997
2089
  # [:a3, :b3, :c3]
1998
2090
  #
1999
- def zip: [Elem2] (_Each[Elem2] enum) -> Array[[ Elem, Elem2? ]]
2091
+ def zip: [Elem2] (_Each[Elem2] enum) -> Array[[ E, Elem2? ]]
2000
2092
  | (_Each[untyped], *_Each[untyped]) -> Array[Array[untyped]]
2001
- | [Elem2] (_Each[Elem2]) { ([ Elem, Elem2? ]) -> void } -> nil
2093
+ | [Elem2] (_Each[Elem2]) { ([ E, Elem2? ]) -> void } -> nil
2002
2094
  | (_Each[untyped], *_Each[untyped]) { (Array[untyped]) -> void } -> nil
2003
2095
 
2004
2096
  # <!--
@@ -2048,8 +2140,8 @@ module Enumerable[unchecked out Elem] : _Each[Elem]
2048
2140
  # ["E", 8736]
2049
2141
  # ["F", 6860]
2050
2142
  #
2051
- # You can use the special symbol `:_alone` to force an element into its own
2052
- # separate chuck:
2143
+ # You can use the special symbol <code>:_alone</code> to force an element into
2144
+ # its own separate chunk:
2053
2145
  #
2054
2146
  # a = [0, 0, 1, 1]
2055
2147
  # e = a.chunk{|i| i.even? ? :_alone : true }
@@ -2064,8 +2156,8 @@ module Enumerable[unchecked out Elem] : _Each[Elem]
2064
2156
  # }
2065
2157
  # }
2066
2158
  #
2067
- # You can use the special symbol `:_separator` or `nil` to force an element to
2068
- # be ignored (not included in any chunk):
2159
+ # You can use the special symbol <code>:_separator</code> or `nil` to force an
2160
+ # element to be ignored (not included in any chunk):
2069
2161
  #
2070
2162
  # a = [0, 0, -1, 1, 1]
2071
2163
  # e = a.chunk{|i| i < 0 ? :_separator : true }
@@ -2105,8 +2197,8 @@ module Enumerable[unchecked out Elem] : _Each[Elem]
2105
2197
  # pp lines
2106
2198
  # }
2107
2199
  #
2108
- def chunk: [U] () { (Elem elt) -> U } -> ::Enumerator[[ U, ::Array[Elem] ]]
2109
- | () -> ::Enumerator[Elem, ::Enumerator[[ untyped, ::Array[Elem] ]]]
2200
+ def chunk: [U] () { (E elt) -> U } -> ::Enumerator[[ U, ::Array[E] ]]
2201
+ | () -> ::Enumerator[E, ::Enumerator[[ untyped, ::Array[E] ]]]
2110
2202
 
2111
2203
  # <!--
2112
2204
  # rdoc-file=enum.c
@@ -2155,7 +2247,7 @@ module Enumerable[unchecked out Elem] : _Each[Elem]
2155
2247
  # Enumerable#slice_when does the same, except splitting when the block returns
2156
2248
  # `true` instead of `false`.
2157
2249
  #
2158
- def chunk_while: () { (Elem elt_before, Elem elt_after) -> boolish } -> ::Enumerator[::Array[Elem]]
2250
+ def chunk_while: () { (E elt_before, E elt_after) -> boolish } -> ::Enumerator[::Array[E]]
2159
2251
 
2160
2252
  # <!--
2161
2253
  # rdoc-file=enum.c
@@ -2217,7 +2309,7 @@ module Enumerable[unchecked out Elem] : _Each[Elem]
2217
2309
  # Enumerable#chunk_while does the same, except splitting when the block returns
2218
2310
  # `false` instead of `true`.
2219
2311
  #
2220
- def slice_when: () { (Elem elt_before, Elem elt_after) -> boolish } -> ::Enumerator[::Array[Elem]]
2312
+ def slice_when: () { (E elt_before, E elt_after) -> boolish } -> ::Enumerator[::Array[E]]
2221
2313
 
2222
2314
  # <!--
2223
2315
  # rdoc-file=enum.c
@@ -2227,11 +2319,11 @@ module Enumerable[unchecked out Elem] : _Each[Elem]
2227
2319
  # Creates an enumerator for each chunked elements. The ends of chunks are
2228
2320
  # defined by *pattern* and the block.
2229
2321
  #
2230
- # If *`pattern* === *elt`* returns `true` or the block returns `true` for the
2231
- # element, the element is end of a chunk.
2322
+ # If <code>_pattern_ === _elt_</code> returns `true` or the block returns `true`
2323
+ # for the element, the element is end of a chunk.
2232
2324
  #
2233
- # The `===` and *block* is called from the first element to the last element of
2234
- # *enum*.
2325
+ # The <code>===</code> and *block* is called from the first element to the last
2326
+ # element of *enum*.
2235
2327
  #
2236
2328
  # The result enumerator yields the chunked elements as an array. So `each`
2237
2329
  # method can be called as follows:
@@ -2252,8 +2344,8 @@ module Enumerable[unchecked out Elem] : _Each[Elem]
2252
2344
  # p e.map {|ll| ll[0...-1].map {|l| l.sub(/\\\n\z/, "") }.join + ll.last }
2253
2345
  # #=>["foo\n", "barbaz\n", "\n", "qux\n"]
2254
2346
  #
2255
- def slice_after: (untyped pattern) -> ::Enumerator[::Array[Elem]]
2256
- | () { (Elem elt) -> boolish } -> ::Enumerator[::Array[Elem]]
2347
+ def slice_after: (untyped pattern) -> ::Enumerator[::Array[E]]
2348
+ | () { (E elt) -> boolish } -> ::Enumerator[::Array[E]]
2257
2349
 
2258
2350
  # <!--
2259
2351
  # rdoc-file=enum.c
@@ -2262,7 +2354,7 @@ module Enumerable[unchecked out Elem] : _Each[Elem]
2262
2354
  # -->
2263
2355
  # With argument `pattern`, returns an enumerator that uses the pattern to
2264
2356
  # partition elements into arrays ("slices"). An element begins a new slice if
2265
- # `element === pattern` (or if it is the first element).
2357
+ # <code>element === pattern</code> (or if it is the first element).
2266
2358
  #
2267
2359
  # a = %w[foo bar fop for baz fob fog bam foy]
2268
2360
  # e = a.slice_before(/ba/) # => #<Enumerator: ...>
@@ -2409,6 +2501,6 @@ module Enumerable[unchecked out Elem] : _Each[Elem]
2409
2501
  # }
2410
2502
  # }
2411
2503
  #
2412
- def slice_before: (untyped pattern) -> ::Enumerator[::Array[Elem]]
2413
- | () { (Elem elt) -> boolish } -> ::Enumerator[::Array[Elem]]
2504
+ def slice_before: (untyped pattern) -> ::Enumerator[::Array[E]]
2505
+ | () { (E elt) -> boolish } -> ::Enumerator[::Array[E]]
2414
2506
  end