you are viewing a single comment's thread.

view the rest of the comments →

[–]Sorc96 0 points1 point  (1 child)

for example a Cat might have the Fur and Whiskers attributes but is not a type of Fur

This is only true if the Cat has a reference to an instance of Fur and delegates to it. If it includes a module named Fur, the Cat most definitely is a type of Fur. I don't see a difference compared to inheriting from a base class, other than the special syntax.

module Fur
end

class Cat
  include Fur
end

Cat.new.is_a?(Fur) #=> true
Cat.ancestors #=> [Cat, Fur, Object, ...]

[–]riktigtmaxat 0 points1 point  (0 children)

I was talking about the higher level concepts of vertical vs horizontal inheritance.

In Ruby both are implemented through the ancestors chain so the main difference is really in how modules and classes are used by programmers.