Enumerable for Fun & Profit
summary
Shows concretely how hand‑rolled loops, counters and ad hoc arrays get replaced by Enumerable primitives, with tests running green while refactors land. Demonstrates using take and lazy to pull first N items from an infinite range, uses map/collect, select/reject/detect and partition for transformation and filtering, and explains inject for accumulation. Replaces a messy prime‑finder with natural_numbers.select(&:prime?).first(n) and proves the simpler code actually works.
AI-written summary · about
chapters (18)
- 0:00Introduction to Enumerable
- 2:30What Enumerable Provides
- 4:14Implementing first_n_elements
- 9:09Using take method
- 10:15Checking with any?
- 14:28Testing with all?
- 16:38Verifying with none?
- 18:11Mapping elements
- 20:30Selecting elements
- 23:16Rejecting elements
- 25:19Finding first match
- 26:44Building with inject
- 30:27Filtering emails with grep
- 34:30Partitioning elements
- 36:29Zipping collections
- 37:55Cycling collections
- 40:01Generating primes
- 44:00Summary & Q&A








