Chapter 14. Callable and runnable objects
- Proc objects as anonymous functions
- The lambda method for generating functions
- Code blocks
- Method objects
- 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 concurrently? 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 call the one you need. ...
Get The Well-Grounded Rubyist, Third Edition now with the O’Reilly learning platform.
O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.