Created
September 22, 2010 17:28
-
-
Save anonymous/592123 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
Animal = Class.new do | |
def initialize(name) | |
@name = name | |
end | |
def speak | |
puts "my name is #{@name}" | |
end | |
end | |
Dog = Class.new(Animal) do | |
def speak | |
puts "my name is #{@name}, I have just met you and I love you, SQUIRREL!" | |
end | |
def bark | |
puts "woof!" | |
end | |
end | |
jimmy = Animal.new("Jimmy") | |
jimmy.speak | |
doug = Dog.new('Doug') | |
doug.speak | |
doug.bark |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment