Created
June 12, 2009 15:16
-
-
Save edward/128696 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
module Dad | |
def self.make_breakfast | |
things_i_like("I like toast.") | |
puts "These are the things we should make for breakfast." | |
end | |
def self.things_i_like(things) | |
puts things | |
end | |
end | |
module Son | |
include Dad | |
def self.make_breakfast | |
super("I like cereal.") # This part doesn't work because there's no class | |
# hierarchy and modules don't have inheritance but | |
# can I do something similar to get the same effect? | |
end | |
def self.things_i_like(things) | |
puts things | |
puts "(But no peanut butter, ok?)" | |
end | |
end | |
Dad::make_breakfast | |
# => I like toast | |
# => These are the things we should make for breakfast. | |
Son::make_breakfast | |
# => I like cereal | |
# => These are the things we should make for breakfast. | |
# => (But no peanut butter, ok?) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment