Skip to content

Instantly share code, notes, and snippets.

Created September 22, 2010 17:28
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save anonymous/592123 to your computer and use it in GitHub Desktop.
Save anonymous/592123 to your computer and use it in GitHub Desktop.
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