CSC/ECE 517 Fall 2012/ch1b 1w60 ac: Difference between revisions

From Expertiza_Wiki
Jump to navigation Jump to search
No edit summary
No edit summary
Line 5: Line 5:
===The Map & Grep Functions===
===The Map & Grep Functions===
==The yield() Function==
==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===
===Syntax===
In it's most basic form, the yield function can be called with simply:
<pre>
yield
</pre>
You can also pass parameters to the yield function, like so:
<pre>
yield parameter
</pre>
===How It Works===
===How It Works===
===Why It's Useful===
===Why It's Useful===

Revision as of 21:39, 29 September 2012

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