I like to say I started programming by accident. While facilitating a Lego robotics club during my teaching years, I was surprised to realize how much I enjoyed coding. Later, when I first learned Ruby as a full-time developer, I rediscovered that joy.
A big reason for my love of Ruby is the Enumerable module because of its simple, functional style and ability to be combined and chained to form useful constructs - a lot like Legos.
I recently gave a talk at both NYC.rb and DCRUG about some great features of
Enumerable that deserve more attention. I touch on interesting use cases for using
Enumerator including API client libraries, streaming HTTP, web crawlers, CSV parsing, and infinite sequences.
I put together a bunch of code samples for the talk and assembled them in a repository on GitHub:
To run a sample, clone the repo and install the gems:
$ git clone https://github.com/rossta/loves-enumerable.git $ cd loves-enumerable $ bundle install
Then simply run the code with the ruby executable.
$ ruby code/pascals_triangle.rb
You'll get the most out of this repo by inspecting the source along with following the presentation.