Skip to content

Comment on (Python) Generator Tricks For Systems Programmer (pdf)

Comments

Is there an equivalent in Ruby?

Not as high level as Python's generator expressions, but you can use Ruby's fibers to implement generators.

Enumerator solves typical generator scenarios reasonably well, and are easy to implement for your own classes. They use Fibers internally, and include Enumerable. Enumerator supports both internal and external iteration.

AboutSource Built by g1lg1l

Hackerly is an independent reader for Hacker News, built on the public HN API. Not affiliated with Y Combinator.