A past puzzle — fully playable. 4 attempts, hints on wrong guesses.
stdle-75.rb
1multiply=->(a,b){a*b}
2double=multiply.curry.(2)
3putsdouble.(7)
4puts[1,2,3,4].map(&double).inspect
Blocks
Answer & explanation
Console output
14
[2, 4, 6, 8]
Why
`curry` returns a new proc that collects arguments until all parameters are satisfied. `multiply.curry.(2)` returns a proc with `a` fixed to `2`, waiting for `b`. This curried proc can be passed to `map` via `&` to double each element.