https://github.com/joyofrails/ruby-enumeration-demo
An interactive visualization of eager and lazy enumeration in Ruby
https://github.com/joyofrails/ruby-enumeration-demo
eager enumeration lazy ruby
Last synced: 8 months ago
JSON representation
An interactive visualization of eager and lazy enumeration in Ruby
- Host: GitHub
- URL: https://github.com/joyofrails/ruby-enumeration-demo
- Owner: joyofrails
- License: mit
- Created: 2024-12-18T15:27:41.000Z (about 1 year ago)
- Default Branch: main
- Last Pushed: 2025-01-17T03:40:51.000Z (11 months ago)
- Last Synced: 2025-04-17T22:41:52.721Z (8 months ago)
- Topics: eager, enumeration, lazy, ruby
- Language: TypeScript
- Homepage: https://joyofrails.github.io/ruby-enumeration-demo/
- Size: 133 KB
- Stars: 0
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# Ruby Enumeration Demo
A visualization of eager and lazy enumeration in Ruby.
[](https://joyofrails.github.io/ruby-enumeration-demo/)
https://joyofrails.github.io/ruby-enumeration-demo/
## About
Rubyists love Ruby’s `Enumerable`:
```ruby
1.upto(5).map { |item| item * 2 }.take(3)
# => [2, 4, 6]
```
But Ruby’s `.lazy` enumerator can be confusing:
```ruby
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
```