CSC/ECE 517 Fall 2012/ch1b 1w60 ac

From Expertiza_Wiki
Revision as of 21:39, 29 September 2012 by Cssuich (talk | contribs)
Jump to navigation Jump to search

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

How It Works

Why It's Useful

Examples

Further Readings

References