Sometimes we have classes that represent collections, for example a class Group can represent a collection of members
When we want to iterate over the collection’s members we have to expose them through attr_reader
The problem with this approach is that the consumers of our collection have to know that we named our variable “members” and use it to iterate. If we ever rename this variable, the consumers of our collection have to rename their call as well. Moreover, we can’t control the order of the enumeration. What can we do to fix that?
We can make our collection an Enumerable, and define an “each” method
That way we don’t expose the name of the variable and we can control the order of the enumeration, e.g. in the previous example we can change the :iterate_members_by_name_length with :iterate_members_alphabeticaly