I craft software, mostly on the web. I love best practices, patterns, and functional programming.
Sep 6, 2022 • 8 tweets • 3 min read
#Ruby's Enumerator.produce is a really cool method! It can generate an infinite series where each item is used to calculate the next.
✨ For example the series of even numbers:
Interestingly though, Enumerator.produce cannot be used to generate more complex series like squares because the input from each step is the output of the previous step