Skip to content

Instantly share code, notes, and snippets.

@edward
Created June 12, 2009 15:16
Show Gist options
  • Save edward/128696 to your computer and use it in GitHub Desktop.
Save edward/128696 to your computer and use it in GitHub Desktop.
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