Modules & Mixins

A module is a bundle of behavior, not a blueprint

A class makes instances (Walker.new). A module, written the same way but with module instead of class, never makes instances at all β€” you can't call Trainable.new. A module exists purely to hold methods you want to share across UNRELATED classes:

module Trainable
  def train
    "#{name} is learning a new trick"
  end
end

Where inheritance is single (Puppy has exactly ONE parent, Dog), a class can include as MANY modules as it wants. This is Ruby's real answer to "I need shared behavior from more than one place" β€” the gap single-inheritance left open last lesson.