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

By now you should understand Ruby’s scoping rules and also what closures are. You should also know how to identify a closure when you see one, and point out where the free variables are. You also know what first-class values are and how they are represented in Ruby.

You also implemented simple objects using only lambdas instead of classes. Then, you explored the inner workings of Enumerable#reduce, a very useful method/function in Ruby and especially other functional languages.

In the next chapter, we’ll look at blocks—one of the most unique features in the Ruby language. You’ll learn about the inner workings of enumeration and how to build beautiful DSLs.

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