Skip to Content
Learn
Object-Oriented Programming II
The Marriage of Modules and Classes

What we did in the last exercise might not have seemed strange to you, but think about it: we mixed together the behaviors of a class and a module!

When a module is used to mix additional behavior and information into a class, it’s called a mixin. Mixins allow us to customize a class without having to rewrite code!

Instructions

Check out the code in the editor. See how we define the jump method in the Action module, then mix it into the Rabbit and Cricket classes? Click Run to see the effect!

Folder Icon

Take this course for free

Already have an account?