-
Notifications
You must be signed in to change notification settings - Fork 216
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Kernel instance methods #1945
Kernel instance methods #1945
Conversation
@@ -2782,8 +2779,7 @@ module Kernel : BasicObject | |||
# | |||
# 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 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The default implementation doesn't actually check the arguments and always returns false, but the documentation says it can also take a String
, so I added that.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is meant to be an abstract method but with a default implementation given.
0a3ac8c
to
b1a6b95
Compare
@@ -2447,7 +2445,7 @@ module Kernel : BasicObject | |||
# b.instance_of? B #=> true | |||
# b.instance_of? C #=> false | |||
# | |||
def instance_of?: (Module) -> bool | |||
def instance_of?: (Module | Class module_or_class) -> bool |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Technically Class < Module
, and the | Class
is redundant.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
While the | Class
is technically redundant, i think it works well as a documentation—new ruby users might not know that all classes are modules, and might be confused as to why is_a?
and friends don't say they accept Class
es
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Has there been discussion in Ruby Core on making Class
not outright inherit from Module
?
Class
is not a strict subtype of Module
because of the many places that can complain “wrong argument type Class (expected Module) (TypeError)”.
include Class
|
||
%a{annotate:rdoc:skip} | ||
# <!-- |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Wow, we have two RDoc entries for yield_self
and then
... 🤔
db0988c
to
81d239d
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
👍
This PR updates all the instance methods on
Kernel
, and also adds tests for them.