Each: A Brief History of Iteration
summary
A grounded tour of iteration history and concrete code shows how to implement linked list each implementation that yields elements and hence enables Enumerable to_a/collect/detect/select (each returns self); builds a Fibonacci using Enumerator and Enumerator::Yielder so the enumerator is an infinite sequence you can call next or take; benchmarks demonstrate collect + compact beats an inject-based comprehension; and practical examples of defining hash and eql for hash keys plus inspect and coercions make custom collections behave correctly in Ruby’s ecosystem.
AI-written summary · about
chapters (13)
- 0:00Start
- 1:45A Brief History of Iteration
- 1:55External Iteration
- 4:20The Semantics of #each
- 5:14For Each Element
- 9:19#detect
- 9:50Caveat Implementor
- 10:41Basis Method
- 13:27Defining #hash
- 15:52The Moral of the Story
- 16:47Other Common Ruby Semantics Your Classes Should Understand
- 18:26Generators
- 27:27#select








