Created
March 12, 2014 16:21
-
-
Save alebaffa/9510440 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
class Shape | |
def rotate | |
'Rotating around the center of ' + self.class.name | |
end | |
def play_sound | |
"I am playing the sound #{self.class.name}.aif" | |
end | |
end | |
class Amoeba < Shape | |
def rotate | |
'I am rotating around a end point!' | |
end | |
def play_sound | |
'I am playing the sound amoeba.hif' | |
end | |
end | |
Square = Class.new(Shape) # -> this should return an instance of Shape | |
#Square.rotate #-> so, I was expecting that calling rotate here would work. But instead it doesn't. | |
puts Square.new.rotate #-> I am forced to call Square.new everytime .... why? | |
puts Square.new.play_sound |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment