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 trialAndrew Walters
8,876 PointsWhy 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?
gunnargabrielson
4,652 PointsYeah I don't really understand this either. Seems really tedious.
1 Answer
JoJo KoKo
4,712 PointsIn short, mixins are Rubys way of doing multiple inheritance since classes.
JoJo KoKo
4,712 Pointsin Ruby can only one inheritance.
JoJo KoKo
4,712 PointsJoJo KoKo
4,712 PointsFor 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.