Ruby on Rails Study Guide: Blocks, Procs, and Lambdas

Ruby is a language with a set of powerful features – the most powerful arguably being Blocks, Procs, and Lambdas. In short, these features allow you to pass code to a method and execute that code at a later time. Despite regularly using these features, many developers don’t fully understand the subtle differences between them. Study Guides: When applying for a programming job, you’ll often be presented with a quiz that intends to determine your level of knowledge and experience in a given subject. The various articles in this series provide condensed solutions to the questions that you might expect to see on such tests. Blocks A block is code that is implicitly passed to a method through the use of either curly braces, {...} , or do...end syntax. It’s common convention to use {...} for single line blocks, and do...end for multi-line blocks. For example, the following block...