CSC/ECE 517 Fall 2012/ch1b 1w60 ac
SaaS - 3.8 yield()
Introduction (Preface)
Code Blocks & Closures
The Map & Grep Functions
The yield() Function
What Is It?
Simply put, the yield function in Ruby allows the execution of a code block. The code block used by the yield function can be passed as a parameter to the function using yield, or it can be declared elsewhere.
Syntax
In it's most basic form, the yield function can be called with simply:
yield
You can also pass parameters to the yield function, like so:
yield parameter