core/kernel.rbs in rbs-3.5.3 vs core/kernel.rbs in rbs-3.6.0.dev.1

- old
+ new

@@ -280,11 +280,11 @@ # receiver, as #class is also a reserved word in Ruby. # # 1.class #=> Integer # self.class #=> Object # - def class: () -> untyped + def class: () -> Class # <!-- # rdoc-file=vm_eval.c # - eval(string [, binding [, filename [,lineno]]]) -> obj # --> @@ -2064,11 +2064,11 @@ # - obj !~ other -> true or false # --> # Returns true if two objects do not match (using the *=~* method), otherwise # false. # - def !~: (untyped) -> bool + def !~: (untyped other) -> bool # <!-- # rdoc-file=object.c # - obj <=> other -> 0 or nil # --> @@ -2084,21 +2084,21 @@ # compared. # # When you define #<=>, you can include Comparable to gain the methods #<=, #<, # #==, #>=, #> and #between?. # - def <=>: (untyped) -> Integer? + def <=>: (untyped other) -> 0? # <!-- # rdoc-file=object.c # - obj === other -> true or false # --> # Case Equality -- For class Object, effectively the same as calling `#==`, but # typically overridden by descendants to provide meaningful semantics in `case` # statements. # - def ===: (untyped) -> bool + alias === == # <!-- # rdoc-file=kernel.rb # - obj.clone(freeze: nil) -> an_object # --> @@ -2150,12 +2150,12 @@ # # chris = "Chris" # chris.define_singleton_method(:greet) {|greeting| "#{greeting}, I'm Chris!" } # chris.greet("Hi") #=> "Hi, I'm Chris!" # - def define_singleton_method: (interned, Method | UnboundMethod | Proc method) -> Symbol - | (interned) { (*untyped) -> untyped } -> Symbol + def define_singleton_method: (interned name, Method | UnboundMethod | Proc method) -> Symbol + | (interned name) { (?) -> untyped } -> Symbol # <!-- # rdoc-file=io.c # - display(port = $>) -> nil # --> @@ -2168,11 +2168,11 @@ # # Output: # # 1cat[4, 5, 6] # - def display: (?_Writer port) -> void + def display: (?_Writer port) -> nil # <!-- # rdoc-file=object.c # - obj.dup -> an_object # --> @@ -2208,11 +2208,11 @@ # s2.foo #=> "foo" # # s3 = s1.dup #=> #<Klass:0x401c1084> # s3.foo #=> NoMethodError: undefined method `foo' for #<Klass:0x401c1084> # - def dup: () -> self + def dup: () -> instance # <!-- rdoc-file=enumerator.c --> # Creates a new Enumerator which will enumerate by calling `method` on `obj`, # passing `args` if any. What was *yielded* by method becomes values of # enumerator. @@ -2265,14 +2265,12 @@ # enum = (1..14).repeat(3) # # => returns an Enumerator when called without a block # enum.first(4) # => [1, 1, 1, 2] # enum.size # => 42 # - def enum_for: (Symbol method, *untyped, **untyped) ?{ (*untyped, **untyped) -> Integer } -> Enumerator[untyped, untyped] - | () ?{ () -> Integer } -> Enumerator[untyped, self] + def enum_for: (?interned method, *untyped, **untyped) ?{ (*untyped, **untyped) -> Integer } -> Enumerator[untyped, untyped] - %a{annotate:rdoc:skip} alias to_enum enum_for # <!-- # rdoc-file=object.c # - obj == other -> true or false @@ -2306,11 +2304,11 @@ # conversion across #==, but not across #eql?, so: # # 1 == 1.0 #=> true # 1.eql? 1.0 #=> false # - def eql?: (untyped) -> bool + def eql?: (untyped other) -> bool # <!-- # rdoc-file=eval.c # - obj.extend(module, ...) -> obj # --> @@ -2331,11 +2329,11 @@ # k = Klass.new # k.hello #=> "Hello from Klass.\n" # k.extend(Mod) #=> #<Klass:0x401b3bc8> # k.hello #=> "Hello from Mod.\n" # - def extend: (Module, *Module) -> self + def extend: (Module module, *Module other_modules) -> self # <!-- # rdoc-file=object.c # - obj.freeze -> obj # --> @@ -2445,11 +2443,11 @@ # b = B.new # b.instance_of? A #=> false # b.instance_of? B #=> true # b.instance_of? C #=> false # - def instance_of?: (Module) -> bool + def instance_of?: (Module | Class module_or_class) -> bool # <!-- # rdoc-file=object.c # - obj.instance_variable_defined?(symbol) -> true or false # - obj.instance_variable_defined?(string) -> true or false @@ -2465,11 +2463,11 @@ # fred = Fred.new('cat', 99) # fred.instance_variable_defined?(:@a) #=> true # fred.instance_variable_defined?("@b") #=> true # fred.instance_variable_defined?("@c") #=> false # - def instance_variable_defined?: (interned var) -> bool + def instance_variable_defined?: (interned variable) -> bool # <!-- # rdoc-file=object.c # - obj.instance_variable_get(symbol) -> obj # - obj.instance_variable_get(string) -> obj @@ -2487,11 +2485,11 @@ # end # fred = Fred.new('cat', 99) # fred.instance_variable_get(:@a) #=> "cat" # fred.instance_variable_get("@b") #=> 99 # - def instance_variable_get: (interned var) -> untyped + def instance_variable_get: (interned variable) -> untyped # <!-- # rdoc-file=object.c # - obj.instance_variable_set(symbol, obj) -> obj # - obj.instance_variable_set(string, obj) -> obj @@ -2510,11 +2508,11 @@ # fred = Fred.new('cat', 99) # fred.instance_variable_set(:@a, 'dog') #=> "dog" # fred.instance_variable_set(:@c, 'cat') #=> "cat" # fred.inspect #=> "#<Fred:0x401b3da8 @a=\"dog\", @b=99, @c=\"cat\">" # - def instance_variable_set: [X] (interned var, X value) -> X + def instance_variable_set: [T] (interned variable, T value) -> T # <!-- # rdoc-file=object.c # - obj.instance_variables -> array # --> @@ -2551,13 +2549,12 @@ # b.kind_of? A #=> true # b.kind_of? B #=> true # b.kind_of? C #=> false # b.kind_of? M #=> true # - def is_a?: (Module) -> bool + def is_a?: (Module | Class module_or_class) -> bool - %a{annotate:rdoc:skip} alias kind_of? is_a? # <!-- # rdoc-file=object.c # - obj.itself -> obj @@ -2634,22 +2631,22 @@ # # module M123; def m123; end end # k.extend M123 # k.methods(false) #=> [:singleton_method] # - def methods: () -> Array[Symbol] + def methods: (?boolish regular) -> Array[Symbol] # <!-- # rdoc-file=object.c # - obj.nil? -> true or false # --> # Only the object *nil* responds `true` to `nil?`. # # Object.new.nil? #=> false # nil.nil? #=> true # - def nil?: () -> bool + def nil?: () -> false # <!-- # rdoc-file=gc.c # - obj.__id__ -> integer # - obj.object_id -> integer @@ -2670,31 +2667,31 @@ # Object.new.object_id == Object.new.object_id # => false # (21 * 2).object_id == (21 * 2).object_id # => true # "hello".object_id == "hello".object_id # => false # "hi".freeze.object_id == "hi".freeze.object_id # => true # - def object_id: () -> Integer + alias object_id __id__ # <!-- # rdoc-file=object.c # - obj.private_methods(all=true) -> array # --> # Returns the list of private methods accessible to *obj*. If the *all* # parameter is set to `false`, only those methods in the receiver will be # listed. # - def private_methods: () -> Array[Symbol] + def private_methods: (?boolish all) -> Array[Symbol] # <!-- # rdoc-file=object.c # - obj.protected_methods(all=true) -> array # --> # Returns the list of protected methods accessible to *obj*. If the *all* # parameter is set to `false`, only those methods in the receiver will be # listed. # - def protected_methods: () -> Array[Symbol] + def protected_methods: (?boolish all) -> Array[Symbol] # <!-- # rdoc-file=proc.c # - obj.public_method(sym) -> method # --> @@ -2720,11 +2717,11 @@ # Unlike send, public_send calls public methods only. When the method is # identified by a string, the string is converted to a symbol. # # 1.public_send(:puts, "hello") # causes NoMethodError # - def public_send: (interned name, *untyped args) ?{ (*untyped) -> untyped } -> untyped + def public_send: (interned name, *untyped, **untyped) ?{ (?) -> untyped } -> untyped # <!-- # rdoc-file=object.c # - obj.remove_instance_variable(symbol) -> obj # - obj.remove_instance_variable(string) -> obj @@ -2744,11 +2741,11 @@ # d = Dummy.new # d.var #=> 99 # d.remove #=> 99 # d.var #=> nil # - def remove_instance_variable: (interned name) -> untyped + def remove_instance_variable: (interned variable) -> untyped # <!-- # rdoc-file=vm_method.c # - obj.respond_to?(symbol, include_all=false) -> true or false # - obj.respond_to?(string, include_all=false) -> true or false @@ -2780,12 +2777,11 @@ # When the method name parameter is given as a string, the string is converted # to a symbol. # # See #respond_to?, and the example of BasicObject. # - %a{annotate:rdoc:copy:Object#respond_to_missing?} - private def respond_to_missing?: (Symbol, bool) -> bool + private def respond_to_missing?: (Symbol | String name, bool include_all) -> bool # <!-- # rdoc-file=vm_eval.c # - foo.send(symbol [, args...]) -> obj # - foo.__send__(symbol [, args...]) -> obj @@ -2806,11 +2802,11 @@ # end # end # k = Klass.new # k.send :hello, "gentle", "readers" #=> "Hello gentle readers" # - def send: (interned name, *untyped args) ?{ (*untyped) -> untyped } -> untyped + alias send __send__ # <!-- # rdoc-file=object.c # - obj.singleton_class -> class # --> @@ -2881,11 +2877,11 @@ # # Single.singleton_methods #=> [:four] # a.singleton_methods(false) #=> [:two, :one] # a.singleton_methods #=> [:two, :one, :three] # - def singleton_methods: () -> Array[Symbol] + def singleton_methods: (?boolish all) -> Array[Symbol] # <!-- # rdoc-file=kernel.rb # - obj.tap {|x| block } -> obj # --> @@ -2917,19 +2913,52 @@ # --> # Yields self to the block and returns the result of the block. # # "my string".yield_self {|s| s.upcase } #=> "MY STRING" # - def yield_self: [X] () { (self) -> X } -> X - | () -> Enumerator[self, untyped] + def yield_self: () -> Enumerator[self, untyped] + | [T] () { (self) -> T } -> T - %a{annotate:rdoc:skip} + # <!-- + # rdoc-file=kernel.rb + # - obj.then {|x| block } -> an_object + # --> + # Yields self to the block and returns the result of the block. + # + # 3.next.then {|x| x**x }.to_s #=> "256" + # + # Good usage for `then` is value piping in method chains: + # + # require 'open-uri' + # require 'json' + # + # construct_url(arguments). + # then {|url| URI(url).read }. + # then {|response| JSON.parse(response) } + # + # When called without block, the method returns `Enumerator`, which can be used, + # for example, for conditional circuit-breaking: + # + # # meets condition, no-op + # 1.then.detect(&:odd?) # => 1 + # # does not meet condition, drop value + # 2.then.detect(&:odd?) # => nil + # + # Good usage for `then` is value piping in method chains: + # + # require 'open-uri' + # require 'json' + # + # construct_url(arguments). + # then {|url| URI(url).read }. + # then {|response| JSON.parse(response) } + # alias then yield_self - private def initialize_copy: (self object) -> self + private - private def initialize_clone: (self object, ?freeze: bool?) -> self + def initialize_copy: (instance object) -> self - private def initialize_dup: (self object) -> self -end + def initialize_clone: (instance object, ?freeze: bool?) -> self -Kernel::RUBYGEMS_ACTIVATION_MONITOR: untyped + def initialize_dup: (instance object) -> self +end