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 ...
Get Programming Ruby 3.3 now with the O’Reilly learning platform.
O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.