From: 7stud -- Date: 2007-09-26T23:26:43+09:00 Subject: Re: difference between inheritance and mixin > what is the use of mixin and what is the use of inheritance 1) class FourLeggedAnimal def speed puts "I run fast." end end class Mammal def birth puts "My babies don't hatch from eggs." end end class Dog < FourLeggedAnimal def speak puts "Bark, bark." end end d = Dog.new d.speak d.speed d.birth --output:-- Bark, bark. I run fast. r6test.rb:21: undefined method `birth' for # (NoMethodError) 2) class FourLeggedAnimal def speed puts "I run fast." end end module Mammal def birth puts "My babies don't hatch from eggs." end end class Dog < FourLeggedAnimal include Mammal def speak puts "Bark, bark." end end d = Dog.new d.speak d.speed d.birth --ouput:-- Bark, bark. I run fast. My babies don't hatch from eggs. -- Posted via http://www.ruby-forum.com/.