0Pricing
Ruby Academy · Lesson

Mixins and Modules

Use modules and mixins to extend class functionality without traditional inheritance.

1

Mixins and Modules

Modules allow code organization and reuse without traditional inheritance.

Mixins enable multiple classes to share behavior without being directly related.

In this lesson, you will learn how to use modules and mixins in Ruby.

Mixins and Modules — illustration 1

2

Defining a Module

Modules are defined using the module keyword and cannot be instantiated.

module Greetings
  def say_hello
    puts 'Hello!'
  end
end

All lessons in this course

  1. Classes and Objects
  2. Instance Variables and Methods
  3. Inheritance and Polymorphism
  4. Mixins and Modules
← Back to Ruby Academy