Skip to content

Instantly share code, notes, and snippets.

@ahmadajmi
Created March 27, 2011 12:51
Show Gist options
  • Save ahmadajmi/889179 to your computer and use it in GitHub Desktop.
Save ahmadajmi/889179 to your computer and use it in GitHub Desktop.
class Animal
attr_accessor :name
def initialize(name)
@name = name
end
end
class Cat < Animal
def talk
@name
end
end
class Mat < Animal
def talk
@name
end
end
class Fat < Mat
def talk
@name
end
end
animal = [Cat.new("My Boom"), Mat.new("My Mat"), Cat.new("New Cat"), Fat.new("skld")]
animal.each do |an|
puts an.talk
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment