Teach me about yield

I second that. 'plain please, Lucy!


“I must hurry back to my comic book store, where I dispense the insults
rather than absorb them.”


-----Original Message-----
From: jobeicus@hotmail.com [mailto:jobeicus@hotmail.com]
Sent: 23 September 2002 13:15
To: ruby-talk@ruby-lang.org
Subject: Teach me about yield

i’ve programmed computers for the greater portion of my life and find
myself really “set in my ways” when it comes to solving problems. i
have both Dave and Matz’s ruby books and have read the description of
yield numerous times, yet never used a single yield statement in just
over a year of ruby coding.

when do you use yield? has it solved problems for you when you
couldn’t find another solution? how did you first start using yield?

i want to expand my mind and wrap it around this concept, any pointers
(besides RTFM), or sample code would be greatly appreciated

NOTICE: This e-mail and any attachment(s) may contain confidential and
proprietary information of Goss International Corporation and/or its
subsidiaries and may be legally privileged. This e-mail is intended solely
for the addressee. If you are not the addressee, dissemination, copying or
other use of this e-mail or any of its content is strictly prohibited and
may be unlawful. If you are not the intended recipient please inform the
sender immediately and destroy the e-mail and any copies. All liability for
viruses is excluded to the fullest extent permitted by law. Any views
expressed in this message are those of the individual sender. No contract
may be construed by this e-mail.

I second that. 'plain please, Lucy!


I’m very new at this, but I look at using yield wherever in C I would
have used a function pointer.

As an example, c’s qsort(). You pass in the comparitor method there
(Java uses an interface for this). In ruby, your sort could take a
block instead.

(“sort” may not be a great example, as it’s built in a number of
useful places…)



Use your computer to help find a cure for cancer: http://members.ud.com/projects/cancer/

Yahoo IM: michael_s_campbell

Do you Yahoo!?
New DSL Internet Access from SBC & Yahoo!