Enumerable
Ruby’s Enumerable module is the basis for the functionality of all container classes in Ruby. The most common container classes in use are Array, Hash, and sometimes Set, but this functionality applies to any other class that defines an each method and includes the Enumerable module.
In this section, we’ll be talking about features common to all Enumerables. Other sections in this chapter will talk about how the core implementations of Array, Hash, and Set add their own features.
Iterating
The Enumerable module looks for a method called each as the building block for basically all of its functionality. The Enumerable module doesn’t define each; instead, it depends on any class that includes Enumerable to define each. The basic contract ...
Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Read now
Unlock full access