Wrapping Up

Lazy enumerables seem magical when you first encounter them. In fact, even when you start unravelling the pieces that make up lazy enumerables, you will undoubtedly find interesting bits of Ruby that you might not have otherwise encountered.

Before writing this chapter, I had never encountered the Enumerator::Yielder, Enumerator::Generator, or Fiber classes. Thankfully, the Rubinius implementation of Enumerable[6] was a great help. Learning about the behavior of Fiber.yield was the “aha!” moment for me.

What’s Next

Ruby is a language that goes the extra mile to provide syntax that tries to do a lot with little ceremony, yet somehow manages to find just the right balance to make things very readable.

Beneath the pretty syntax ...

Get Mastering Ruby Closures 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.