Don't Fear The Lambda
summary
Argues for using Ruby's Enumerable methods to replace imperative loops: use functional style for returns and use each for side effects. Demonstrates concrete rewrites that become one-liners (detect for first match, any for existence, map+join for string building, flat_map for nested lists) and highlights Ruby 1.9 features (flat_map, map.with_index, enumerators/fibers). Warns that inject is powerful but often unreadable and that pure, immutable rewrites can be slower because Ruby creates new objects compared to mutating updates.
AI-written summary · about
chapters (15)
- 0:00Start
- 1:32Ground Rules
- 1:43If You Return Your Value Use the Functional Style
- 2:43Side Effects
- 4:32Variable Names
- 6:47Flat Map
- 10:47Infinite Range
- 15:00Accumulator with an Array
- 15:54Hash Accumulator
- 17:32Array Accumulator
- 18:47Complex Nested Hash
- 20:20Blur
- 23:57Adding an Index
- 25:22Summary
- 26:52Naming the Parameters
related talks
37mFunctional Programming in Ruby
33mBetter Ruby through Functional Programming
40mMake Ruby Functional Again!
44mFunctional Programming for Rubyists
45mEnumerable for Fun & Profit
28mRuby Lambdas
42mTaking inspiration from the functional world
01h 06mDesigning Applications with Functional Programming Constructs
