Last active
August 29, 2015 13:57
-
-
Save oliverswitzer/9846672 to your computer and use it in GitHub Desktop.
A simple gist demonstrating how Ruby looks up module methods when they've been included in a class
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 Engine | |
def run | |
puts "GRRRRRRRRR" | |
end | |
end | |
class Vehicle | |
def run | |
puts "I'm a thing that moves!" | |
end | |
end | |
class Car < Vehicle | |
include Engine | |
def run | |
puts "I'm driving!" | |
end | |
end | |
myCar = Car.new | |
puts myCar.run |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment