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
Share this Page URL
Help

Chapter 10. Collections central: Enumera... > Enumerators and the next dimension o...

10.9. Enumerators and the next dimension of enumerability

Enumerators are a recent and significant addition to Ruby. Unlike some of the changes between Ruby 1.8 and 1.9, enumerators alter the Ruby programming landscape dramatically. In version 1.8.6, you could use them if you required the necessary library (require 'enumerator'); in 1.9, they’re present when you start up Ruby.

Enumerators are closely related to iterators, but they aren’t the same thing. An iterator is a method that yields one or more values to a code block. An enumerator is an object, not a method.


  

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