Created
December 22, 2010 11:47
-
-
Save banister/751422 to your computer and use it in GitHub Desktop.
This file contains 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 Hello; end | |
Hello.singleton_class.class #=> Class | |
# So methods on Hello.singleton_class should be first looked up as instance methods on Class right? | |
class Class | |
def hello | |
puts "from Class" | |
end | |
end | |
class << Class | |
def hello | |
puts "from (Class)" | |
super | |
end | |
end | |
class << Module | |
def hello | |
puts "from (Module)" | |
super | |
end | |
end | |
class << Object | |
def hello | |
puts "from (Object)" | |
super | |
end | |
end | |
Hello.singleton_class.hello | |
#=> | |
from (Class) | |
from (Module) | |
from (Object) | |
from Class |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment