O'Reilly logo

The Well-Grounded Rubyist by David A. Black

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

Chapter 14. Callable and runnable objects

 

In this chapter

  • Proc objects as anonymous functions
  • The lambda (a.k.a. proc) method
  • Code blocks
  • The Symbol#to_proc method
  • Method objects
  • Bindings
  • The eval family of methods
  • Threads
  • Executing external programs

 

In addition to the basic, bread-and-butter method calls that account for most of what happens in your program, Ruby provides an extensive toolkit for making things happen in a variety of ways. You need two or more parts of your code to run in parallel? Create some Thread objects and run them as needed. Want to choose from among a set of possible functions to execute, and don’t have enough information in advance to write methods for them? Create an array of Proc objects—anonymous functions—and ...

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