O'Reilly logo

Mastering Ruby Closures by Benjamin Tan Wei Hao

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Wrapping Up

Procs and lambdas are powerful tools to have in your Ruby arsenal. Their purpose is simple: to allow pieces of code to be carried around. However, the consequences are far-reaching.

Developers have been using functional programming techniques in Ruby code to great effect. It’s hard to imagine idiomatic Ruby code without functions like map and reduce. However, in order to write idiomatic code using Procs and lambdas, it’s important to understand its usages and nuances.

In a beautifully meta sort of way, Procs and lambdas have been exploited to enhance the Ruby language itself, with Symbol#to_proc as a shining example. Now that you’ve gone through the implementation of Symbol#to_proc, hopefully you realize that there is absolutely ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required