Skip to content

Latest commit

 

History

History
49 lines (31 loc) · 825 Bytes

README.md

File metadata and controls

49 lines (31 loc) · 825 Bytes

Ruby Enumeration Demo

A visualization of eager and lazy enumeration in Ruby.

Screenshot of demo

https://joyofrails.github.io/ruby-enumeration-demo/

About

Rubyists love Ruby’s Enumerable:

1.upto(5).map { |item| item * 2 }.take(3)
# => [2, 4, 6]

But Ruby’s .lazy enumerator can be confusing:

1.upto(5).lazy.map { |item| item * 2 }.take(3).to_a
# => [2, 4, 6]

What’s going on here?

This visualization may help illustrate the difference.

Development

Make sure node and npm is installed. See .node-version for current version.

Install dependencies:

npm install

Run the Vite dev server:

npm run dev

Build static assets

npm run build