Created
October 2, 2021 19:45
-
-
Save searls/ff8cf2a1ac0eaea281d4d0e4be086413 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class Wtf | |
def method_missing(name, *args) | |
:lol | |
end | |
def respond_to?(name) | |
:nope | |
end | |
def respond_to_missing?(name) | |
:kek | |
end | |
end | |
puts "method_missing owner: #{Wtf.instance_method(:method_missing).owner}" | |
puts "respond_to? owner: #{Wtf.instance_method(:respond_to?).owner}" | |
puts "respond_to_missing? owner: #{Wtf.instance_method(:respond_to_missing?).owner}" | |
puts "instance_methods: #{Wtf.instance_methods.select { |m| | |
Wtf.instance_method(m).owner == Wtf | |
}}" |
TIL there are 4 names that will always be private:
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
respond_to_missing?
is always set toprivate
- found the spec for that.