Created
April 20, 2017 15:26
-
-
Save dannyc5/5a05a0319aa41182c4a0b5282d05c20e to your computer and use it in GitHub Desktop.
ruby scope w mixins
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 bee | |
p cee | |
end | |
end | |
module C | |
def cee | |
'hi' | |
end | |
end | |
class A | |
include B | |
include C | |
def hay | |
bee | |
end | |
end | |
a = A.new | |
a.hay # self is a, and all mixed-in methods are visible to a (in a's scope) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment