Module 25 Β· Blocks, Procs & Lambdas β Lesson 5 of 6 Β· ~9 min
Composition & Functional Style
Compose small functions into pipelines
Ruby leans object-oriented but has sharp functional tools. Two lambdas (or method objects) compose with >> and <<: f >> g makes a new callable that runs f then feeds its result to g (left-to-right); f << g runs g then f (right-to-left). Small, named, testable steps assembled into a pipeline beats one long method.
In an interview, say: "
>>composes callables left-to-right into a pipeline. I use it to build a price calculation out of named, individually-testable steps instead of one procedure β each step is pure and the composition documents the flow."