Ryan Ho

Think, Create, Do, Repeat

LinkedIn GitHub Facebook Twitter

Enumerables

November 4, 2015 | Coding

Overview

The Enumerable mixin provides collection classes with several traversal and searching methods, and with the ability to sort. The class must provide a method each, which yields successive members of the collection. If Enumerable#max, #min,code. or #sort is used, the objects in the collection must also implement a meaningful <=> operator, as these methods rely on an ordering between members of the collection.

An example of how to use Ruby's Enumerable is as follows:

Comments box

Name:
Email:
Comments: