Created
June 18, 2012 12:31
-
-
Save edzhelyov/2948165 to your computer and use it in GitHub Desktop.
How Ruby methods are resolved
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
module B | |
def speak | |
'B' | |
end | |
end | |
module C | |
def speak | |
'C' | |
end | |
end | |
class A | |
include B | |
end | |
puts A.new.speak | |
A.send :include, C | |
puts A.new.speak | |
class A | |
def speak | |
'A' | |
end | |
end | |
puts A.new.speak | |
a = A.new | |
puts a.speak | |
def a.speak | |
'a' | |
end | |
puts a.speak |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment