Recall & Review
beginner
What is a mixin in Ruby?
A mixin is a module that you include in a class to add reusable methods without using inheritance.Click to reveal answer
beginner
How do you include a custom module as a mixin in a Ruby class?
Use the <code>include</code> keyword inside the class to add the module's methods as instance methods.Click to reveal answer
intermediate
What is the difference between
include and extend when using modules?<code>include</code> adds module methods as instance methods; <code>extend</code> adds them as class methods.Click to reveal answer
beginner
Can a Ruby class include multiple modules as mixins?Yes, a class can include many modules to combine different sets of methods.Click to reveal answer
intermediate
Why use custom modules as mixins instead of inheritance?
Mixins let you share behavior across unrelated classes without forcing a strict parent-child relationship.Click to reveal answer
How do you add a module's methods as instance methods in a Ruby class?
✗ Incorrect
Use include to add module methods as instance methods.
What keyword adds module methods as class methods to a Ruby class?
✗ Incorrect
extend adds module methods as class methods.
Which of these is true about Ruby modules used as mixins?
✗ Incorrect
Modules let you share methods across different classes without inheritance.
Can a Ruby class include more than one module?
✗ Incorrect
Ruby classes can include many modules to combine behaviors.
Why might you use a module as a mixin instead of inheritance?
✗ Incorrect
Mixins share behavior across classes without forcing inheritance.
Explain how to create and use a custom module as a mixin in Ruby.
Think about how you add shared behavior to different classes.
You got /3 concepts.
Describe the difference between include and extend when using modules in Ruby.
Consider who can call the methods after adding the module.
You got /3 concepts.