Welcome to the Treehouse Community

Want to collaborate on code errors? Have bugs you need feedback on? Looking for an extra set of eyes on your latest project? Get support with fellow developers, designers, and programmers of all backgrounds and skill levels here with the Treehouse Community! While you're at it, check out some resources Treehouse students have shared here.

Looking to learn something new?

Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and join thousands of Treehouse students and alumni in the community today.

Start your free trial

Ruby Ruby Modules Ruby Core Modules Enumerable

Andrew Walters
Andrew Walters
8,876 Points

Why do we need modules?

Hey guys, so I have a bit of confusion here. All throughout the course, we have been using our comparison operators and enumerables like .each/any?/etc just fine. Why are we now having to include these modules and then write methods based upon those modules to use these actions when we've been doing so without the step so far?

For example in Ruby enumerables is a module. If you want to create your own methods to use in other classes and locations, you would need to create something called "mixins" b/c of inheritance. Take a read on "mixins" and modules for a clearer understanding.

Yeah I don't really understand this either. Seems really tedious.

1 Answer

In short, mixins are Rubys way of doing multiple inheritance since classes.

in Ruby can only one inheritance.