Free Trial

Safari Books Online is a digital library providing on-demand subscription access to thousands of learning resources.


  • Create BookmarkCreate Bookmark
  • Create Note or TagCreate Note or Tag
  • DownloadDownload
  • PrintPrint

9.5. Collections

This section documents Ruby’s collection classes. A collection is any class that represents a collection of values. Array and Hash are the key collection classes in Ruby, and the standard library adds a Set class. Each of these collection classes mixes in the Enumerable module, which means that Enumerable methods are universal collection methods.

9.5.1. Enumerable Objects

The Enumerable module is a mixin that implements a number of useful methods on top of the each iterator. The Array, Hash, and Set classes described below all include Enumerable and therefore implement all of the methods described here. Range and IO are other noteworthy enumerable classes. Enumerable was covered briefly in Section 5.3.2. This section provides more detailed coverage.


  

You are currently reading a PREVIEW of this book.

                                                                                        

Get instant access to over
$1 million worth of books and videos.

  

Start a Free Trial


  
  • Safari Books Online
  • Create BookmarkCreate Bookmark
  • Create Note or TagCreate Note or Tag
  • DownloadDownload
  • PrintPrint