On 2/18/06, bbqbaker <none / noine.com> wrote:
> is this kind of right?? thanks

Yep, that's basically it.  Coming from C++, I also had a tough time
with blocks at first (but they are so great, so it's worth the
effort).

I wrote a tutorial that talks, among other things, about a somewhat
different approach to understanding blocks and procs:

  http://pine.fm/LearnToProgram/?Chapter=10

and, of course, it's also covered in my book:

  http://www.pragmaticprogrammer.com/titles/fr_ltp/

(The book covers what's in the tutorial, but considerably more in
depth, and with the benefit of the feedback I got from the tutorial
(which came first), as well as covering things that never made it into
the tutorial.)

Essentially, what I found confusing was "yield".  Once you look at the
problem from the angle of little functions (like the C++ function you
wrote) that you pass around explicitly, it makes more sense (to me, at
least).

Once I wrapped my head around that, it wasn't hard to see yield and
the "do |...| code-code-code end" syntax as just shortcuts to make the
whole process easier to program.

And for the record, I still think "yield" is a weird name for it.  :)

Chris