rbs 3.2.2 → 3.3.0.pre.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (125) hide show
  1. checksums.yaml +4 -4
  2. data/.github/workflows/comments.yml +1 -1
  3. data/.github/workflows/ruby.yml +7 -2
  4. data/CHANGELOG.md +85 -0
  5. data/Gemfile.lock +14 -14
  6. data/README.md +11 -2
  7. data/Rakefile +10 -7
  8. data/Steepfile +7 -7
  9. data/core/basic_object.rbs +7 -7
  10. data/core/binding.rbs +3 -3
  11. data/core/builtin.rbs +171 -5
  12. data/core/constants.rbs +17 -17
  13. data/core/dir.rbs +3 -3
  14. data/core/encoding.rbs +434 -628
  15. data/core/enumerator.rbs +37 -0
  16. data/core/exception.rbs +11 -11
  17. data/core/false_class.rbs +5 -11
  18. data/core/fiber.rbs +3 -3
  19. data/core/file_test.rbs +28 -26
  20. data/core/kernel.rbs +900 -21
  21. data/core/marshal.rbs +24 -14
  22. data/core/match_data.rbs +8 -8
  23. data/core/math.rbs +57 -53
  24. data/core/method.rbs +3 -1
  25. data/core/module.rbs +38 -36
  26. data/core/nil_class.rbs +7 -13
  27. data/core/object.rbs +3 -966
  28. data/core/process.rbs +3 -3
  29. data/core/ractor.rbs +2 -2
  30. data/core/rb_config.rbs +64 -43
  31. data/core/regexp.rbs +3 -3
  32. data/core/signal.rbs +10 -4
  33. data/core/struct.rbs +1 -1
  34. data/core/thread.rbs +7 -7
  35. data/core/thread_group.rbs +9 -9
  36. data/core/true_class.rbs +5 -11
  37. data/core/unbound_method.rbs +56 -7
  38. data/core/warning.rbs +33 -0
  39. data/docs/collection.md +56 -6
  40. data/docs/data_and_struct.md +57 -0
  41. data/docs/stdlib.md +61 -2
  42. data/docs/syntax.md +123 -2
  43. data/ext/rbs_extension/lexer.c +624 -569
  44. data/ext/rbs_extension/lexer.h +1 -0
  45. data/ext/rbs_extension/lexer.re +1 -0
  46. data/ext/rbs_extension/lexstate.c +1 -0
  47. data/ext/rbs_extension/parser.c +6 -0
  48. data/goodcheck.yml +2 -2
  49. data/lib/rbs/annotate/formatter.rb +13 -3
  50. data/lib/rbs/annotate/rdoc_source.rb +10 -1
  51. data/lib/rbs/cli/colored_io.rb +48 -0
  52. data/lib/rbs/cli/diff.rb +80 -0
  53. data/lib/rbs/cli.rb +151 -16
  54. data/lib/rbs/collection/config/lockfile.rb +0 -25
  55. data/lib/rbs/collection/config/lockfile_generator.rb +0 -6
  56. data/lib/rbs/collection/installer.rb +1 -1
  57. data/lib/rbs/collection/sources/git.rb +6 -4
  58. data/lib/rbs/collection/sources/local.rb +7 -5
  59. data/lib/rbs/diff.rb +104 -0
  60. data/lib/rbs/environment.rb +1 -1
  61. data/lib/rbs/method_type.rb +23 -0
  62. data/lib/rbs/prototype/rb.rb +2 -9
  63. data/lib/rbs/prototype/runtime/helpers.rb +59 -0
  64. data/lib/rbs/prototype/runtime/value_object_generator.rb +236 -0
  65. data/lib/rbs/prototype/runtime.rb +234 -150
  66. data/lib/rbs/sorter.rb +144 -117
  67. data/lib/rbs/test/guaranteed.rb +31 -0
  68. data/lib/rbs/test/type_check.rb +4 -4
  69. data/lib/rbs/test.rb +3 -0
  70. data/lib/rbs/types.rb +184 -3
  71. data/lib/rbs/version.rb +1 -1
  72. data/lib/rbs/writer.rb +4 -4
  73. data/lib/rbs.rb +1 -0
  74. data/rbs.gemspec +1 -0
  75. data/sig/annotate/formatter.rbs +2 -2
  76. data/sig/annotate/rdoc_annotater.rbs +1 -1
  77. data/sig/cli/colored_io.rbs +15 -0
  78. data/sig/cli/diff.rbs +21 -0
  79. data/sig/cli.rbs +2 -0
  80. data/sig/collection/config/lockfile.rbs +0 -6
  81. data/sig/diff.rbs +23 -0
  82. data/sig/errors.rbs +1 -5
  83. data/sig/method_types.rbs +6 -0
  84. data/sig/prototype/runtime.rbs +108 -0
  85. data/sig/rdoc/rbs.rbs +4 -0
  86. data/sig/shims/bundler.rbs +5 -0
  87. data/sig/sorter.rbs +23 -5
  88. data/sig/types.rbs +29 -0
  89. data/stdlib/benchmark/0/benchmark.rbs +1 -1
  90. data/stdlib/cgi/0/core.rbs +2 -2
  91. data/stdlib/did_you_mean/0/did_you_mean.rbs +2 -2
  92. data/stdlib/digest/0/digest.rbs +1 -1
  93. data/stdlib/fileutils/0/fileutils.rbs +1 -1
  94. data/stdlib/forwardable/0/forwardable.rbs +4 -4
  95. data/stdlib/io-console/0/io-console.rbs +1 -1
  96. data/stdlib/json/0/json.rbs +37 -0
  97. data/stdlib/logger/0/logger.rbs +2 -2
  98. data/stdlib/net-http/0/manifest.yaml +1 -1
  99. data/stdlib/net-http/0/net-http.rbs +16 -63
  100. data/stdlib/net-protocol/0/manifest.yaml +2 -0
  101. data/stdlib/net-protocol/0/net-protocol.rbs +56 -0
  102. data/stdlib/openssl/0/openssl.rbs +1 -1
  103. data/stdlib/pp/0/manifest.yaml +2 -0
  104. data/stdlib/pp/0/pp.rbs +301 -0
  105. data/stdlib/{yaml → psych}/0/dbm.rbs +3 -3
  106. data/stdlib/psych/0/manifest.yaml +3 -0
  107. data/stdlib/psych/0/psych.rbs +391 -0
  108. data/stdlib/{yaml → psych}/0/store.rbs +2 -2
  109. data/stdlib/rdoc/0/code_object.rbs +55 -0
  110. data/stdlib/rdoc/0/comment.rbs +60 -0
  111. data/stdlib/rdoc/0/context.rbs +153 -0
  112. data/stdlib/rdoc/0/markup.rbs +119 -0
  113. data/stdlib/rdoc/0/parser.rbs +56 -0
  114. data/stdlib/rdoc/0/rdoc.rbs +0 -372
  115. data/stdlib/rdoc/0/ri.rbs +17 -0
  116. data/stdlib/rdoc/0/store.rbs +48 -0
  117. data/stdlib/rdoc/0/top_level.rbs +97 -0
  118. data/stdlib/socket/0/basic_socket.rbs +1 -1
  119. data/stdlib/socket/0/socket.rbs +1 -1
  120. data/stdlib/uri/0/common.rbs +1 -1
  121. data/stdlib/yaml/0/manifest.yaml +1 -2
  122. data/stdlib/yaml/0/yaml.rbs +1 -199
  123. metadata +46 -9
  124. data/sig/shims/pp.rbs +0 -3
  125. data/sig/shims.rbs +0 -47
data/core/kernel.rbs CHANGED
@@ -385,8 +385,6 @@ module Kernel : BasicObject
385
385
  def self?.fork: () -> Integer?
386
386
  | () { () -> void } -> Integer
387
387
 
388
- def initialize_copy: (self object) -> self
389
-
390
388
  # <!--
391
389
  # rdoc-file=object.c
392
390
  # - Array(object) -> object or new_array
@@ -404,8 +402,7 @@ module Kernel : BasicObject
404
402
  # Array(:foo) # => [:foo]
405
403
  #
406
404
  def self?.Array: (nil) -> []
407
- | [T] (Array[T] ary) -> Array[T]
408
- | [T] (_ToAry[T] | _ToA[T] array_like) -> Array[T]
405
+ | [T] (array[T] | _ToA[T] array_like) -> Array[T]
409
406
  | [T] (T ele) -> [T]
410
407
 
411
408
  # <!--
@@ -448,7 +445,7 @@ module Kernel : BasicObject
448
445
  | (_ToC complex_like, exception: bool) -> Complex?
449
446
  | (Numeric | String real, ?Numeric | String imag, ?exception: true) -> Complex
450
447
  | (Numeric | String real, ?Numeric | String imag, exception: bool) -> Complex?
451
- | (untyped, ?untyped, exception: false) -> nil
448
+ | (untyped, ?untyped, ?exception: bool) -> Complex?
452
449
 
453
450
  # <!--
454
451
  # rdoc-file=kernel.rb
@@ -468,7 +465,7 @@ module Kernel : BasicObject
468
465
  #
469
466
  def self?.Float: (_ToF float_like, ?exception: true) -> Float
470
467
  | (_ToF float_like, exception: bool) -> Float?
471
- | (untyped, exception: false) -> nil
468
+ | (untyped, ?exception: bool) -> Float?
472
469
 
473
470
  # <!--
474
471
  # rdoc-file=object.c
@@ -493,7 +490,7 @@ module Kernel : BasicObject
493
490
  # Hash([]) # => {}
494
491
  #
495
492
  def self?.Hash: [K, V] (nil | [] _empty) -> Hash[K, V]
496
- | [K, V] (_ToHash[K, V] hash_like) -> Hash[K, V]
493
+ | [K, V] (hash[K, V] hash_like) -> Hash[K, V]
497
494
 
498
495
  # <!--
499
496
  # rdoc-file=object.c
@@ -579,11 +576,11 @@ module Kernel : BasicObject
579
576
  # With `exception` given as `false`, an exception of any kind is suppressed and
580
577
  # `nil` is returned.
581
578
  #
582
- def self?.Integer: (_ToInt | _ToI int_like, ?exception: true) -> Integer
583
- | (_ToInt | _ToI int_like, exception: bool) -> Integer?
584
- | (string str, ?int base, ?exception: true) -> Integer
585
- | (string str, ?int base, exception: bool) -> Integer?
586
- | (untyped, ?untyped, exception: false) -> nil
579
+ def self?.Integer: (int | _ToI int_like, ?exception: true) -> Integer
580
+ | (int | _ToI int_like, exception: bool) -> Integer?
581
+ | (string str, int base, ?exception: true) -> Integer
582
+ | (string str, int base, exception: bool) -> Integer?
583
+ | (untyped, ?untyped, ?exception: bool) -> Integer?
587
584
 
588
585
  # <!--
589
586
  # rdoc-file=rational.c
@@ -622,13 +619,13 @@ module Kernel : BasicObject
622
619
  #
623
620
  # See also String#to_r.
624
621
  #
625
- def self?.Rational: (_ToInt | _ToR rational_like, ?exception: true) -> Rational
626
- | (_ToInt | _ToR rational_like, exception: bool) -> Rational?
627
- | (_ToInt | _ToR numer, ?_ToInt | _ToR denom, ?exception: true) -> Rational
628
- | (_ToInt | _ToR numer, ?_ToInt | _ToR denom, exception: bool) -> Rational?
622
+ def self?.Rational: (int | _ToR rational_like, ?exception: true) -> Rational
623
+ | (int | _ToR rational_like, exception: bool) -> Rational?
624
+ | (int | _ToR numer, ?int | _ToR denom, ?exception: true) -> Rational
625
+ | (int | _ToR numer, ?int | _ToR denom, exception: bool) -> Rational?
629
626
  | [T] (Numeric&_RationalDiv[T] numer, Numeric denom, ?exception: bool) -> T
630
627
  | [T < Numeric] (T value, 1, ?exception: bool) -> T
631
- | (untyped, ?untyped, exception: false) -> nil
628
+ | (untyped, ?untyped, ?exception: bool) -> Rational?
632
629
 
633
630
  interface _RationalDiv[T]
634
631
  def /: (Numeric) -> T
@@ -745,7 +742,7 @@ module Kernel : BasicObject
745
742
  # If *const* is defined as autoload, the file name to be loaded is replaced with
746
743
  # *filename*. If *const* is defined but not as autoload, does nothing.
747
744
  #
748
- def self?.autoload: (String | Symbol _module, String filename) -> NilClass
745
+ def self?.autoload: (interned _module, String filename) -> NilClass
749
746
 
750
747
  # <!--
751
748
  # rdoc-file=load.c
@@ -756,7 +753,7 @@ module Kernel : BasicObject
756
753
  # autoload(:B, "b")
757
754
  # autoload?(:B) #=> "b"
758
755
  #
759
- def self?.autoload?: (Symbol | String name) -> String?
756
+ def self?.autoload?: (interned name) -> String?
760
757
 
761
758
  # <!--
762
759
  # rdoc-file=proc.c
@@ -846,7 +843,8 @@ module Kernel : BasicObject
846
843
  #
847
844
  def self?.fail: () -> bot
848
845
  | (string message, ?cause: Exception?) -> bot
849
- | (_Exception exception, ?_ToS? message, ?nil | String | Array[String] backtrace, ?cause: Exception?) -> bot
846
+ | (_Exception exception, ?_ToS? message, ?String | Array[String] | nil backtrace, ?cause: Exception?) -> bot
847
+ | (_Exception exception, ?cause: Exception?, **untyped) -> bot
850
848
 
851
849
  # <!--
852
850
  # rdoc-file=eval.c
@@ -1568,7 +1566,7 @@ module Kernel : BasicObject
1568
1566
  # Time.new #=> 2008-03-08 19:56:22 +0900
1569
1567
  #
1570
1568
  def self?.sleep: (?nil) -> bot
1571
- | ((Integer | Float | _Divmod) duration) -> Integer
1569
+ | (Integer | Float | _Divmod duration) -> Integer
1572
1570
 
1573
1571
  interface _Divmod
1574
1572
  def divmod: (Numeric) -> [ Numeric, Numeric ]
@@ -2097,6 +2095,887 @@ module Kernel : BasicObject
2097
2095
  #
2098
2096
  def self?.system: (String command, *String args, ?unsetenv_others: boolish, ?pgroup: true | Integer, ?umask: Integer, ?in: redirect_fd, ?out: redirect_fd, ?err: redirect_fd, ?close_others: boolish, ?chdir: String) -> (NilClass | FalseClass | TrueClass)
2099
2097
  | (Hash[string, string?] env, String command, *String args, ?unsetenv_others: boolish, ?pgroup: true | Integer, ?umask: Integer, ?in: redirect_fd, ?out: redirect_fd, ?err: redirect_fd, ?close_others: boolish, ?chdir: String) -> (NilClass | FalseClass | TrueClass)
2098
+
2099
+ # <!--
2100
+ # rdoc-file=object.c
2101
+ # - obj !~ other -> true or false
2102
+ # -->
2103
+ # Returns true if two objects do not match (using the *=~* method), otherwise
2104
+ # false.
2105
+ #
2106
+ def !~: (untyped) -> bool
2107
+
2108
+ # <!--
2109
+ # rdoc-file=object.c
2110
+ # - obj <=> other -> 0 or nil
2111
+ # -->
2112
+ # Returns 0 if `obj` and `other` are the same object or `obj == other`,
2113
+ # otherwise nil.
2114
+ #
2115
+ # The #<=> is used by various methods to compare objects, for example
2116
+ # Enumerable#sort, Enumerable#max etc.
2117
+ #
2118
+ # Your implementation of #<=> should return one of the following values: -1, 0,
2119
+ # 1 or nil. -1 means self is smaller than other. 0 means self is equal to other.
2120
+ # 1 means self is bigger than other. Nil means the two values could not be
2121
+ # compared.
2122
+ #
2123
+ # When you define #<=>, you can include Comparable to gain the methods #<=, #<,
2124
+ # #==, #>=, #> and #between?.
2125
+ #
2126
+ def <=>: (untyped) -> Integer?
2127
+
2128
+ # <!--
2129
+ # rdoc-file=object.c
2130
+ # - obj === other -> true or false
2131
+ # -->
2132
+ # Case Equality -- For class Object, effectively the same as calling `#==`, but
2133
+ # typically overridden by descendants to provide meaningful semantics in `case`
2134
+ # statements.
2135
+ #
2136
+ def ===: (untyped) -> bool
2137
+
2138
+ # <!--
2139
+ # rdoc-file=kernel.rb
2140
+ # - obj.clone(freeze: nil) -> an_object
2141
+ # -->
2142
+ # Produces a shallow copy of *obj*---the instance variables of *obj* are copied,
2143
+ # but not the objects they reference. #clone copies the frozen value state of
2144
+ # *obj*, unless the `:freeze` keyword argument is given with a false or true
2145
+ # value. See also the discussion under Object#dup.
2146
+ #
2147
+ # class Klass
2148
+ # attr_accessor :str
2149
+ # end
2150
+ # s1 = Klass.new #=> #<Klass:0x401b3a38>
2151
+ # s1.str = "Hello" #=> "Hello"
2152
+ # s2 = s1.clone #=> #<Klass:0x401b3998 @str="Hello">
2153
+ # s2.str[1,4] = "i" #=> "i"
2154
+ # s1.inspect #=> "#<Klass:0x401b3a38 @str=\"Hi\">"
2155
+ # s2.inspect #=> "#<Klass:0x401b3998 @str=\"Hi\">"
2156
+ #
2157
+ # This method may have class-specific behavior. If so, that behavior will be
2158
+ # documented under the #`initialize_copy` method of the class.
2159
+ #
2160
+ def clone: (?freeze: bool?) -> self
2161
+
2162
+ # <!--
2163
+ # rdoc-file=proc.c
2164
+ # - define_singleton_method(symbol, method) -> symbol
2165
+ # - define_singleton_method(symbol) { block } -> symbol
2166
+ # -->
2167
+ # Defines a public singleton method in the receiver. The *method* parameter can
2168
+ # be a `Proc`, a `Method` or an `UnboundMethod` object. If a block is specified,
2169
+ # it is used as the method body. If a block or a method has parameters, they're
2170
+ # used as method parameters.
2171
+ #
2172
+ # class A
2173
+ # class << self
2174
+ # def class_name
2175
+ # to_s
2176
+ # end
2177
+ # end
2178
+ # end
2179
+ # A.define_singleton_method(:who_am_i) do
2180
+ # "I am: #{class_name}"
2181
+ # end
2182
+ # A.who_am_i # ==> "I am: A"
2183
+ #
2184
+ # guy = "Bob"
2185
+ # guy.define_singleton_method(:hello) { "#{self}: Hello there!" }
2186
+ # guy.hello #=> "Bob: Hello there!"
2187
+ #
2188
+ # chris = "Chris"
2189
+ # chris.define_singleton_method(:greet) {|greeting| "#{greeting}, I'm Chris!" }
2190
+ # chris.greet("Hi") #=> "Hi, I'm Chris!"
2191
+ #
2192
+ def define_singleton_method: (interned, Method | UnboundMethod | Proc method) -> Symbol
2193
+ | (interned) { (*untyped) -> untyped } -> Symbol
2194
+
2195
+ # <!--
2196
+ # rdoc-file=io.c
2197
+ # - display(port = $>) -> nil
2198
+ # -->
2199
+ # Writes `self` on the given port:
2200
+ #
2201
+ # 1.display
2202
+ # "cat".display
2203
+ # [ 4, 5, 6 ].display
2204
+ # puts
2205
+ #
2206
+ # Output:
2207
+ #
2208
+ # 1cat[4, 5, 6]
2209
+ #
2210
+ def display: (?_Writer port) -> void
2211
+
2212
+ # <!--
2213
+ # rdoc-file=object.c
2214
+ # - obj.dup -> an_object
2215
+ # -->
2216
+ # Produces a shallow copy of *obj*---the instance variables of *obj* are copied,
2217
+ # but not the objects they reference.
2218
+ #
2219
+ # This method may have class-specific behavior. If so, that behavior will be
2220
+ # documented under the #`initialize_copy` method of the class.
2221
+ #
2222
+ # ### on dup vs clone
2223
+ #
2224
+ # In general, #clone and #dup may have different semantics in descendant
2225
+ # classes. While #clone is used to duplicate an object, including its internal
2226
+ # state, #dup typically uses the class of the descendant object to create the
2227
+ # new instance.
2228
+ #
2229
+ # When using #dup, any modules that the object has been extended with will not
2230
+ # be copied.
2231
+ #
2232
+ # class Klass
2233
+ # attr_accessor :str
2234
+ # end
2235
+ #
2236
+ # module Foo
2237
+ # def foo; 'foo'; end
2238
+ # end
2239
+ #
2240
+ # s1 = Klass.new #=> #<Klass:0x401b3a38>
2241
+ # s1.extend(Foo) #=> #<Klass:0x401b3a38>
2242
+ # s1.foo #=> "foo"
2243
+ #
2244
+ # s2 = s1.clone #=> #<Klass:0x401be280>
2245
+ # s2.foo #=> "foo"
2246
+ #
2247
+ # s3 = s1.dup #=> #<Klass:0x401c1084>
2248
+ # s3.foo #=> NoMethodError: undefined method `foo' for #<Klass:0x401c1084>
2249
+ #
2250
+ def dup: () -> self
2251
+
2252
+ # <!-- rdoc-file=enumerator.c -->
2253
+ # Creates a new Enumerator which will enumerate by calling `method` on `obj`,
2254
+ # passing `args` if any. What was *yielded* by method becomes values of
2255
+ # enumerator.
2256
+ #
2257
+ # If a block is given, it will be used to calculate the size of the enumerator
2258
+ # without the need to iterate it (see Enumerator#size).
2259
+ #
2260
+ # ### Examples
2261
+ #
2262
+ # str = "xyz"
2263
+ #
2264
+ # enum = str.enum_for(:each_byte)
2265
+ # enum.each { |b| puts b }
2266
+ # # => 120
2267
+ # # => 121
2268
+ # # => 122
2269
+ #
2270
+ # # protect an array from being modified by some_method
2271
+ # a = [1, 2, 3]
2272
+ # some_method(a.to_enum)
2273
+ #
2274
+ # # String#split in block form is more memory-effective:
2275
+ # very_large_string.split("|") { |chunk| return chunk if chunk.include?('DATE') }
2276
+ # # This could be rewritten more idiomatically with to_enum:
2277
+ # very_large_string.to_enum(:split, "|").lazy.grep(/DATE/).first
2278
+ #
2279
+ # It is typical to call to_enum when defining methods for a generic Enumerable,
2280
+ # in case no block is passed.
2281
+ #
2282
+ # Here is such an example, with parameter passing and a sizing block:
2283
+ #
2284
+ # module Enumerable
2285
+ # # a generic method to repeat the values of any enumerable
2286
+ # def repeat(n)
2287
+ # raise ArgumentError, "#{n} is negative!" if n < 0
2288
+ # unless block_given?
2289
+ # return to_enum(__method__, n) do # __method__ is :repeat here
2290
+ # sz = size # Call size and multiply by n...
2291
+ # sz * n if sz # but return nil if size itself is nil
2292
+ # end
2293
+ # end
2294
+ # each do |*val|
2295
+ # n.times { yield *val }
2296
+ # end
2297
+ # end
2298
+ # end
2299
+ #
2300
+ # %i[hello world].repeat(2) { |w| puts w }
2301
+ # # => Prints 'hello', 'hello', 'world', 'world'
2302
+ # enum = (1..14).repeat(3)
2303
+ # # => returns an Enumerator when called without a block
2304
+ # enum.first(4) # => [1, 1, 1, 2]
2305
+ # enum.size # => 42
2306
+ #
2307
+ def enum_for: (Symbol method, *untyped, **untyped) ?{ (*untyped, **untyped) -> Integer } -> Enumerator[untyped, untyped]
2308
+ | () ?{ () -> Integer } -> Enumerator[untyped, self]
2309
+
2310
+ %a{annotate:rdoc:skip}
2311
+ alias to_enum enum_for
2312
+
2313
+ # <!--
2314
+ # rdoc-file=object.c
2315
+ # - obj == other -> true or false
2316
+ # - obj.equal?(other) -> true or false
2317
+ # - obj.eql?(other) -> true or false
2318
+ # -->
2319
+ # Equality --- At the Object level, #== returns `true` only if `obj` and `other`
2320
+ # are the same object. Typically, this method is overridden in descendant
2321
+ # classes to provide class-specific meaning.
2322
+ #
2323
+ # Unlike #==, the #equal? method should never be overridden by subclasses as it
2324
+ # is used to determine object identity (that is, `a.equal?(b)` if and only if
2325
+ # `a` is the same object as `b`):
2326
+ #
2327
+ # obj = "a"
2328
+ # other = obj.dup
2329
+ #
2330
+ # obj == other #=> true
2331
+ # obj.equal? other #=> false
2332
+ # obj.equal? obj #=> true
2333
+ #
2334
+ # The #eql? method returns `true` if `obj` and `other` refer to the same hash
2335
+ # key. This is used by Hash to test members for equality. For any pair of
2336
+ # objects where #eql? returns `true`, the #hash value of both objects must be
2337
+ # equal. So any subclass that overrides #eql? should also override #hash
2338
+ # appropriately.
2339
+ #
2340
+ # For objects of class Object, #eql? is synonymous with #==. Subclasses
2341
+ # normally continue this tradition by aliasing #eql? to their overridden #==
2342
+ # method, but there are exceptions. Numeric types, for example, perform type
2343
+ # conversion across #==, but not across #eql?, so:
2344
+ #
2345
+ # 1 == 1.0 #=> true
2346
+ # 1.eql? 1.0 #=> false
2347
+ #
2348
+ def eql?: (untyped) -> bool
2349
+
2350
+ # <!--
2351
+ # rdoc-file=eval.c
2352
+ # - obj.extend(module, ...) -> obj
2353
+ # -->
2354
+ # Adds to *obj* the instance methods from each module given as a parameter.
2355
+ #
2356
+ # module Mod
2357
+ # def hello
2358
+ # "Hello from Mod.\n"
2359
+ # end
2360
+ # end
2361
+ #
2362
+ # class Klass
2363
+ # def hello
2364
+ # "Hello from Klass.\n"
2365
+ # end
2366
+ # end
2367
+ #
2368
+ # k = Klass.new
2369
+ # k.hello #=> "Hello from Klass.\n"
2370
+ # k.extend(Mod) #=> #<Klass:0x401b3bc8>
2371
+ # k.hello #=> "Hello from Mod.\n"
2372
+ #
2373
+ def extend: (*Module) -> self
2374
+
2375
+ # <!--
2376
+ # rdoc-file=object.c
2377
+ # - obj.freeze -> obj
2378
+ # -->
2379
+ # Prevents further modifications to *obj*. A FrozenError will be raised if
2380
+ # modification is attempted. There is no way to unfreeze a frozen object. See
2381
+ # also Object#frozen?.
2382
+ #
2383
+ # This method returns self.
2384
+ #
2385
+ # a = [ "a", "b", "c" ]
2386
+ # a.freeze
2387
+ # a << "z"
2388
+ #
2389
+ # *produces:*
2390
+ #
2391
+ # prog.rb:3:in `<<': can't modify frozen Array (FrozenError)
2392
+ # from prog.rb:3
2393
+ #
2394
+ # Objects of the following classes are always frozen: Integer, Float, Symbol.
2395
+ #
2396
+ def freeze: () -> self
2397
+
2398
+ # <!--
2399
+ # rdoc-file=kernel.rb
2400
+ # - obj.frozen? -> true or false
2401
+ # -->
2402
+ # Returns the freeze status of *obj*.
2403
+ #
2404
+ # a = [ "a", "b", "c" ]
2405
+ # a.freeze #=> ["a", "b", "c"]
2406
+ # a.frozen? #=> true
2407
+ #
2408
+ def frozen?: () -> bool
2409
+
2410
+ # <!--
2411
+ # rdoc-file=object.c
2412
+ # - obj.hash -> integer
2413
+ # -->
2414
+ # Generates an Integer hash value for this object. This function must have the
2415
+ # property that `a.eql?(b)` implies `a.hash == b.hash`.
2416
+ #
2417
+ # The hash value is used along with #eql? by the Hash class to determine if two
2418
+ # objects reference the same hash key. Any hash value that exceeds the capacity
2419
+ # of an Integer will be truncated before being used.
2420
+ #
2421
+ # The hash value for an object may not be identical across invocations or
2422
+ # implementations of Ruby. If you need a stable identifier across Ruby
2423
+ # invocations and implementations you will need to generate one with a custom
2424
+ # method.
2425
+ #
2426
+ # Certain core classes such as Integer use built-in hash calculations and do not
2427
+ # call the #hash method when used as a hash key.
2428
+ #
2429
+ # When implementing your own #hash based on multiple values, the best practice
2430
+ # is to combine the class and any values using the hash code of an array:
2431
+ #
2432
+ # For example:
2433
+ #
2434
+ # def hash
2435
+ # [self.class, a, b, c].hash
2436
+ # end
2437
+ #
2438
+ # The reason for this is that the Array#hash method already has logic for safely
2439
+ # and efficiently combining multiple hash values.
2440
+ #
2441
+ def hash: () -> Integer
2442
+
2443
+ # <!--
2444
+ # rdoc-file=object.c
2445
+ # - obj.inspect -> string
2446
+ # -->
2447
+ # Returns a string containing a human-readable representation of *obj*. The
2448
+ # default #inspect shows the object's class name, an encoding of its memory
2449
+ # address, and a list of the instance variables and their values (by calling
2450
+ # #inspect on each of them). User defined classes should override this method
2451
+ # to provide a better representation of *obj*. When overriding this method, it
2452
+ # should return a string whose encoding is compatible with the default external
2453
+ # encoding.
2454
+ #
2455
+ # [ 1, 2, 3..4, 'five' ].inspect #=> "[1, 2, 3..4, \"five\"]"
2456
+ # Time.new.inspect #=> "2008-03-08 19:43:39 +0900"
2457
+ #
2458
+ # class Foo
2459
+ # end
2460
+ # Foo.new.inspect #=> "#<Foo:0x0300c868>"
2461
+ #
2462
+ # class Bar
2463
+ # def initialize
2464
+ # @bar = 1
2465
+ # end
2466
+ # end
2467
+ # Bar.new.inspect #=> "#<Bar:0x0300c868 @bar=1>"
2468
+ #
2469
+ def inspect: () -> String
2470
+
2471
+ # <!--
2472
+ # rdoc-file=object.c
2473
+ # - obj.instance_of?(class) -> true or false
2474
+ # -->
2475
+ # Returns `true` if *obj* is an instance of the given class. See also
2476
+ # Object#kind_of?.
2477
+ #
2478
+ # class A; end
2479
+ # class B < A; end
2480
+ # class C < B; end
2481
+ #
2482
+ # b = B.new
2483
+ # b.instance_of? A #=> false
2484
+ # b.instance_of? B #=> true
2485
+ # b.instance_of? C #=> false
2486
+ #
2487
+ def instance_of?: (Module) -> bool
2488
+
2489
+ # <!--
2490
+ # rdoc-file=object.c
2491
+ # - obj.instance_variable_defined?(symbol) -> true or false
2492
+ # - obj.instance_variable_defined?(string) -> true or false
2493
+ # -->
2494
+ # Returns `true` if the given instance variable is defined in *obj*. String
2495
+ # arguments are converted to symbols.
2496
+ #
2497
+ # class Fred
2498
+ # def initialize(p1, p2)
2499
+ # @a, @b = p1, p2
2500
+ # end
2501
+ # end
2502
+ # fred = Fred.new('cat', 99)
2503
+ # fred.instance_variable_defined?(:@a) #=> true
2504
+ # fred.instance_variable_defined?("@b") #=> true
2505
+ # fred.instance_variable_defined?("@c") #=> false
2506
+ #
2507
+ def instance_variable_defined?: (interned var) -> bool
2508
+
2509
+ # <!--
2510
+ # rdoc-file=object.c
2511
+ # - obj.instance_variable_get(symbol) -> obj
2512
+ # - obj.instance_variable_get(string) -> obj
2513
+ # -->
2514
+ # Returns the value of the given instance variable, or nil if the instance
2515
+ # variable is not set. The `@` part of the variable name should be included for
2516
+ # regular instance variables. Throws a NameError exception if the supplied
2517
+ # symbol is not valid as an instance variable name. String arguments are
2518
+ # converted to symbols.
2519
+ #
2520
+ # class Fred
2521
+ # def initialize(p1, p2)
2522
+ # @a, @b = p1, p2
2523
+ # end
2524
+ # end
2525
+ # fred = Fred.new('cat', 99)
2526
+ # fred.instance_variable_get(:@a) #=> "cat"
2527
+ # fred.instance_variable_get("@b") #=> 99
2528
+ #
2529
+ def instance_variable_get: (interned var) -> untyped
2530
+
2531
+ # <!--
2532
+ # rdoc-file=object.c
2533
+ # - obj.instance_variable_set(symbol, obj) -> obj
2534
+ # - obj.instance_variable_set(string, obj) -> obj
2535
+ # -->
2536
+ # Sets the instance variable named by *symbol* to the given object. This may
2537
+ # circumvent the encapsulation intended by the author of the class, so it should
2538
+ # be used with care. The variable does not have to exist prior to this call. If
2539
+ # the instance variable name is passed as a string, that string is converted to
2540
+ # a symbol.
2541
+ #
2542
+ # class Fred
2543
+ # def initialize(p1, p2)
2544
+ # @a, @b = p1, p2
2545
+ # end
2546
+ # end
2547
+ # fred = Fred.new('cat', 99)
2548
+ # fred.instance_variable_set(:@a, 'dog') #=> "dog"
2549
+ # fred.instance_variable_set(:@c, 'cat') #=> "cat"
2550
+ # fred.inspect #=> "#<Fred:0x401b3da8 @a=\"dog\", @b=99, @c=\"cat\">"
2551
+ #
2552
+ def instance_variable_set: [X] (interned var, X value) -> X
2553
+
2554
+ # <!--
2555
+ # rdoc-file=object.c
2556
+ # - obj.instance_variables -> array
2557
+ # -->
2558
+ # Returns an array of instance variable names for the receiver. Note that simply
2559
+ # defining an accessor does not create the corresponding instance variable.
2560
+ #
2561
+ # class Fred
2562
+ # attr_accessor :a1
2563
+ # def initialize
2564
+ # @iv = 3
2565
+ # end
2566
+ # end
2567
+ # Fred.new.instance_variables #=> [:@iv]
2568
+ #
2569
+ def instance_variables: () -> Array[Symbol]
2570
+
2571
+ # <!-- rdoc-file=object.c -->
2572
+ # Returns `true` if *class* is the class of *obj*, or if *class* is one of the
2573
+ # superclasses of *obj* or modules included in *obj*.
2574
+ #
2575
+ # module M; end
2576
+ # class A
2577
+ # include M
2578
+ # end
2579
+ # class B < A; end
2580
+ # class C < B; end
2581
+ #
2582
+ # b = B.new
2583
+ # b.is_a? A #=> true
2584
+ # b.is_a? B #=> true
2585
+ # b.is_a? C #=> false
2586
+ # b.is_a? M #=> true
2587
+ #
2588
+ # b.kind_of? A #=> true
2589
+ # b.kind_of? B #=> true
2590
+ # b.kind_of? C #=> false
2591
+ # b.kind_of? M #=> true
2592
+ #
2593
+ def is_a?: (Module) -> bool
2594
+
2595
+ %a{annotate:rdoc:skip}
2596
+ alias kind_of? is_a?
2597
+
2598
+ # <!--
2599
+ # rdoc-file=object.c
2600
+ # - obj.itself -> obj
2601
+ # -->
2602
+ # Returns the receiver.
2603
+ #
2604
+ # string = "my string"
2605
+ # string.itself.object_id == string.object_id #=> true
2606
+ #
2607
+ def itself: () -> self
2608
+
2609
+ # <!--
2610
+ # rdoc-file=proc.c
2611
+ # - obj.method(sym) -> method
2612
+ # -->
2613
+ # Looks up the named method as a receiver in *obj*, returning a Method object
2614
+ # (or raising NameError). The Method object acts as a closure in *obj*'s object
2615
+ # instance, so instance variables and the value of `self` remain available.
2616
+ #
2617
+ # class Demo
2618
+ # def initialize(n)
2619
+ # @iv = n
2620
+ # end
2621
+ # def hello()
2622
+ # "Hello, @iv = #{@iv}"
2623
+ # end
2624
+ # end
2625
+ #
2626
+ # k = Demo.new(99)
2627
+ # m = k.method(:hello)
2628
+ # m.call #=> "Hello, @iv = 99"
2629
+ #
2630
+ # l = Demo.new('Fred')
2631
+ # m = l.method("hello")
2632
+ # m.call #=> "Hello, @iv = Fred"
2633
+ #
2634
+ # Note that Method implements `to_proc` method, which means it can be used with
2635
+ # iterators.
2636
+ #
2637
+ # [ 1, 2, 3 ].each(&method(:puts)) # => prints 3 lines to stdout
2638
+ #
2639
+ # out = File.open('test.txt', 'w')
2640
+ # [ 1, 2, 3 ].each(&out.method(:puts)) # => prints 3 lines to file
2641
+ #
2642
+ # require 'date'
2643
+ # %w[2017-03-01 2017-03-02].collect(&Date.method(:parse))
2644
+ # #=> [#<Date: 2017-03-01 ((2457814j,0s,0n),+0s,2299161j)>, #<Date: 2017-03-02 ((2457815j,0s,0n),+0s,2299161j)>]
2645
+ #
2646
+ def method: (interned name) -> Method
2647
+
2648
+ # <!--
2649
+ # rdoc-file=object.c
2650
+ # - obj.methods(regular=true) -> array
2651
+ # -->
2652
+ # Returns a list of the names of public and protected methods of *obj*. This
2653
+ # will include all the methods accessible in *obj*'s ancestors. If the optional
2654
+ # parameter is `false`, it returns an array of *obj*'s public and protected
2655
+ # singleton methods, the array will not include methods in modules included in
2656
+ # *obj*.
2657
+ #
2658
+ # class Klass
2659
+ # def klass_method()
2660
+ # end
2661
+ # end
2662
+ # k = Klass.new
2663
+ # k.methods[0..9] #=> [:klass_method, :nil?, :===,
2664
+ # # :==~, :!, :eql?
2665
+ # # :hash, :<=>, :class, :singleton_class]
2666
+ # k.methods.length #=> 56
2667
+ #
2668
+ # k.methods(false) #=> []
2669
+ # def k.singleton_method; end
2670
+ # k.methods(false) #=> [:singleton_method]
2671
+ #
2672
+ # module M123; def m123; end end
2673
+ # k.extend M123
2674
+ # k.methods(false) #=> [:singleton_method]
2675
+ #
2676
+ def methods: () -> Array[Symbol]
2677
+
2678
+ # <!--
2679
+ # rdoc-file=object.c
2680
+ # - obj.nil? -> true or false
2681
+ # -->
2682
+ # Only the object *nil* responds `true` to `nil?`.
2683
+ #
2684
+ # Object.new.nil? #=> false
2685
+ # nil.nil? #=> true
2686
+ #
2687
+ def nil?: () -> bool
2688
+
2689
+ # <!--
2690
+ # rdoc-file=gc.c
2691
+ # - obj.__id__ -> integer
2692
+ # - obj.object_id -> integer
2693
+ # -->
2694
+ # Returns an integer identifier for `obj`.
2695
+ #
2696
+ # The same number will be returned on all calls to `object_id` for a given
2697
+ # object, and no two active objects will share an id.
2698
+ #
2699
+ # Note: that some objects of builtin classes are reused for optimization. This
2700
+ # is the case for immediate values and frozen string literals.
2701
+ #
2702
+ # BasicObject implements +__id__+, Kernel implements `object_id`.
2703
+ #
2704
+ # Immediate values are not passed by reference but are passed by value: `nil`,
2705
+ # `true`, `false`, Fixnums, Symbols, and some Floats.
2706
+ #
2707
+ # Object.new.object_id == Object.new.object_id # => false
2708
+ # (21 * 2).object_id == (21 * 2).object_id # => true
2709
+ # "hello".object_id == "hello".object_id # => false
2710
+ # "hi".freeze.object_id == "hi".freeze.object_id # => true
2711
+ #
2712
+ def object_id: () -> Integer
2713
+
2714
+ # <!--
2715
+ # rdoc-file=object.c
2716
+ # - obj.private_methods(all=true) -> array
2717
+ # -->
2718
+ # Returns the list of private methods accessible to *obj*. If the *all*
2719
+ # parameter is set to `false`, only those methods in the receiver will be
2720
+ # listed.
2721
+ #
2722
+ def private_methods: () -> Array[Symbol]
2723
+
2724
+ # <!--
2725
+ # rdoc-file=object.c
2726
+ # - obj.protected_methods(all=true) -> array
2727
+ # -->
2728
+ # Returns the list of protected methods accessible to *obj*. If the *all*
2729
+ # parameter is set to `false`, only those methods in the receiver will be
2730
+ # listed.
2731
+ #
2732
+ def protected_methods: () -> Array[Symbol]
2733
+
2734
+ # <!--
2735
+ # rdoc-file=proc.c
2736
+ # - obj.public_method(sym) -> method
2737
+ # -->
2738
+ # Similar to *method*, searches public method only.
2739
+ #
2740
+ def public_method: (interned name) -> Method
2741
+
2742
+ # <!--
2743
+ # rdoc-file=object.c
2744
+ # - obj.public_methods(all=true) -> array
2745
+ # -->
2746
+ # Returns the list of public methods accessible to *obj*. If the *all* parameter
2747
+ # is set to `false`, only those methods in the receiver will be listed.
2748
+ #
2749
+ def public_methods: (?boolish all) -> Array[Symbol]
2750
+
2751
+ # <!--
2752
+ # rdoc-file=vm_eval.c
2753
+ # - obj.public_send(symbol [, args...]) -> obj
2754
+ # - obj.public_send(string [, args...]) -> obj
2755
+ # -->
2756
+ # Invokes the method identified by *symbol*, passing it any arguments specified.
2757
+ # Unlike send, public_send calls public methods only. When the method is
2758
+ # identified by a string, the string is converted to a symbol.
2759
+ #
2760
+ # 1.public_send(:puts, "hello") # causes NoMethodError
2761
+ #
2762
+ def public_send: (interned name, *untyped args) ?{ (*untyped) -> untyped } -> untyped
2763
+
2764
+ # <!--
2765
+ # rdoc-file=object.c
2766
+ # - obj.remove_instance_variable(symbol) -> obj
2767
+ # - obj.remove_instance_variable(string) -> obj
2768
+ # -->
2769
+ # Removes the named instance variable from *obj*, returning that variable's
2770
+ # value. String arguments are converted to symbols.
2771
+ #
2772
+ # class Dummy
2773
+ # attr_reader :var
2774
+ # def initialize
2775
+ # @var = 99
2776
+ # end
2777
+ # def remove
2778
+ # remove_instance_variable(:@var)
2779
+ # end
2780
+ # end
2781
+ # d = Dummy.new
2782
+ # d.var #=> 99
2783
+ # d.remove #=> 99
2784
+ # d.var #=> nil
2785
+ #
2786
+ def remove_instance_variable: (interned name) -> untyped
2787
+
2788
+ # <!--
2789
+ # rdoc-file=vm_method.c
2790
+ # - obj.respond_to?(symbol, include_all=false) -> true or false
2791
+ # - obj.respond_to?(string, include_all=false) -> true or false
2792
+ # -->
2793
+ # Returns `true` if *obj* responds to the given method. Private and protected
2794
+ # methods are included in the search only if the optional second parameter
2795
+ # evaluates to `true`.
2796
+ #
2797
+ # If the method is not implemented, as Process.fork on Windows, File.lchmod on
2798
+ # GNU/Linux, etc., false is returned.
2799
+ #
2800
+ # If the method is not defined, `respond_to_missing?` method is called and the
2801
+ # result is returned.
2802
+ #
2803
+ # When the method name parameter is given as a string, the string is converted
2804
+ # to a symbol.
2805
+ #
2806
+ def respond_to?: (interned name, ?boolish include_all) -> bool
2807
+
2808
+ # <!--
2809
+ # rdoc-file=vm_method.c
2810
+ # - obj.respond_to_missing?(symbol, include_all) -> true or false
2811
+ # - obj.respond_to_missing?(string, include_all) -> true or false
2812
+ # -->
2813
+ # DO NOT USE THIS DIRECTLY.
2814
+ #
2815
+ # Hook method to return whether the *obj* can respond to *id* method or not.
2816
+ #
2817
+ # When the method name parameter is given as a string, the string is converted
2818
+ # to a symbol.
2819
+ #
2820
+ # See #respond_to?, and the example of BasicObject.
2821
+ #
2822
+ %a{annotate:rdoc:copy:Object#respond_to_missing?}
2823
+ private def respond_to_missing?: (Symbol, bool) -> bool
2824
+
2825
+ # <!--
2826
+ # rdoc-file=vm_eval.c
2827
+ # - foo.send(symbol [, args...]) -> obj
2828
+ # - foo.__send__(symbol [, args...]) -> obj
2829
+ # - foo.send(string [, args...]) -> obj
2830
+ # - foo.__send__(string [, args...]) -> obj
2831
+ # -->
2832
+ # Invokes the method identified by *symbol*, passing it any arguments specified.
2833
+ # When the method is identified by a string, the string is converted to a
2834
+ # symbol.
2835
+ #
2836
+ # BasicObject implements +__send__+, Kernel implements `send`. `__send__` is
2837
+ # safer than `send` when *obj* has the same method name like `Socket`. See also
2838
+ # `public_send`.
2839
+ #
2840
+ # class Klass
2841
+ # def hello(*args)
2842
+ # "Hello " + args.join(' ')
2843
+ # end
2844
+ # end
2845
+ # k = Klass.new
2846
+ # k.send :hello, "gentle", "readers" #=> "Hello gentle readers"
2847
+ #
2848
+ def send: (interned name, *untyped args) ?{ (*untyped) -> untyped } -> untyped
2849
+
2850
+ # <!--
2851
+ # rdoc-file=object.c
2852
+ # - obj.singleton_class -> class
2853
+ # -->
2854
+ # Returns the singleton class of *obj*. This method creates a new singleton
2855
+ # class if *obj* does not have one.
2856
+ #
2857
+ # If *obj* is `nil`, `true`, or `false`, it returns NilClass, TrueClass, or
2858
+ # FalseClass, respectively. If *obj* is an Integer, a Float or a Symbol, it
2859
+ # raises a TypeError.
2860
+ #
2861
+ # Object.new.singleton_class #=> #<Class:#<Object:0xb7ce1e24>>
2862
+ # String.singleton_class #=> #<Class:String>
2863
+ # nil.singleton_class #=> NilClass
2864
+ #
2865
+ def singleton_class: () -> Class
2866
+
2867
+ # <!--
2868
+ # rdoc-file=proc.c
2869
+ # - obj.singleton_method(sym) -> method
2870
+ # -->
2871
+ # Similar to *method*, searches singleton method only.
2872
+ #
2873
+ # class Demo
2874
+ # def initialize(n)
2875
+ # @iv = n
2876
+ # end
2877
+ # def hello()
2878
+ # "Hello, @iv = #{@iv}"
2879
+ # end
2880
+ # end
2881
+ #
2882
+ # k = Demo.new(99)
2883
+ # def k.hi
2884
+ # "Hi, @iv = #{@iv}"
2885
+ # end
2886
+ # m = k.singleton_method(:hi)
2887
+ # m.call #=> "Hi, @iv = 99"
2888
+ # m = k.singleton_method(:hello) #=> NameError
2889
+ #
2890
+ def singleton_method: (interned name) -> Method
2891
+
2892
+ # <!--
2893
+ # rdoc-file=object.c
2894
+ # - obj.singleton_methods(all=true) -> array
2895
+ # -->
2896
+ # Returns an array of the names of singleton methods for *obj*. If the optional
2897
+ # *all* parameter is true, the list will include methods in modules included in
2898
+ # *obj*. Only public and protected singleton methods are returned.
2899
+ #
2900
+ # module Other
2901
+ # def three() end
2902
+ # end
2903
+ #
2904
+ # class Single
2905
+ # def Single.four() end
2906
+ # end
2907
+ #
2908
+ # a = Single.new
2909
+ #
2910
+ # def a.one()
2911
+ # end
2912
+ #
2913
+ # class << a
2914
+ # include Other
2915
+ # def two()
2916
+ # end
2917
+ # end
2918
+ #
2919
+ # Single.singleton_methods #=> [:four]
2920
+ # a.singleton_methods(false) #=> [:two, :one]
2921
+ # a.singleton_methods #=> [:two, :one, :three]
2922
+ #
2923
+ def singleton_methods: () -> Array[Symbol]
2924
+
2925
+ # <!--
2926
+ # rdoc-file=kernel.rb
2927
+ # - obj.tap {|x| block } -> obj
2928
+ # -->
2929
+ # Yields self to the block, and then returns self. The primary purpose of this
2930
+ # method is to "tap into" a method chain, in order to perform operations on
2931
+ # intermediate results within the chain.
2932
+ #
2933
+ # (1..10) .tap {|x| puts "original: #{x}" }
2934
+ # .to_a .tap {|x| puts "array: #{x}" }
2935
+ # .select {|x| x.even? } .tap {|x| puts "evens: #{x}" }
2936
+ # .map {|x| x*x } .tap {|x| puts "squares: #{x}" }
2937
+ #
2938
+ def tap: () { (self) -> void } -> self
2939
+
2940
+ # <!--
2941
+ # rdoc-file=object.c
2942
+ # - obj.to_s -> string
2943
+ # -->
2944
+ # Returns a string representing *obj*. The default #to_s prints the object's
2945
+ # class and an encoding of the object id. As a special case, the top-level
2946
+ # object that is the initial execution context of Ruby programs returns
2947
+ # ``main''.
2948
+ #
2949
+ def to_s: () -> String
2950
+
2951
+ # <!--
2952
+ # rdoc-file=kernel.rb
2953
+ # - obj.yield_self {|x| block } -> an_object
2954
+ # -->
2955
+ # Yields self to the block and returns the result of the block.
2956
+ #
2957
+ # "my string".yield_self {|s| s.upcase } #=> "MY STRING"
2958
+ #
2959
+ # Good usage for `then` is value piping in method chains:
2960
+ #
2961
+ # require 'open-uri'
2962
+ # require 'json'
2963
+ #
2964
+ # construct_url(arguments).
2965
+ # then {|url| URI(url).read }.
2966
+ # then {|response| JSON.parse(response) }
2967
+ #
2968
+ def yield_self: [X] () { (self) -> X } -> X
2969
+ | () -> Enumerator[self, untyped]
2970
+
2971
+ %a{annotate:rdoc:skip}
2972
+ alias then yield_self
2973
+
2974
+ private def initialize_copy: (self object) -> self
2975
+
2976
+ private def initialize_clone: (self object, ?freeze: bool?) -> self
2977
+
2978
+ private def initialize_dup: (self object) -> self
2100
2979
  end
2101
2980
 
2102
2981
  Kernel::RUBYGEMS_ACTIVATION_MONITOR: untyped