Join Kevin Skoglund for an in-depth discussion in this video Enumerable as a mixin, part of Ruby Essential Training.
Before we leave modules and move on, I want to give you a little bit of insight…into way that Ruby uses modules inside its standard library of classes.…Now, we've seen a number of methods so far, like sort, detect, select, reject,…collect, and inject and even more that are shared between a number of different classes.…We saw how we could use these on arrays and hashes and ranges and strings, and…that they are used in more classes as well.…And they might have slightly different behaviors on each one, but the same…functionality essentially is part of all these classes.…
When you have shared functionality like that, it's a good indication that a…module may be at work, and that's exactly what's happening with these classes.…So here I am taking a look at the Ruby documentation at ruby-doc.org in the core…library, and I've got a definition for array.…Now we see all the methods that are in array, but notice here, it says…Included Modules>Enumerable.…Enumerable is an included module in array.…Let's take a look at Hash, scroll down Included Modules>Enumerable and Range,…
- Using Ruby in the Interactive Ruby Shell and in standalone scripts
- Learning to write custom code blocks to find, merge, and sort
- Using modules for namespacing or as mix-ins
- Reading from and writing to files
- Creating a full Ruby project from start to finish
Skill Level Beginner
1. Getting Started with Ruby
2. Ruby Object Types
3. Control Structures
4. Code Blocks
8. Working with Files
9. Ruby Project: Creating the Food Finder
- Mark as unwatched
- Mark all as unwatched
Are you sure you want to mark all the videos in this course as unwatched?
Take notes with your new membership!
Type in the entry box, then click Enter to save your note.
1:30Press on any video thumbnail to jump immediately to the timecode shown.