He Fa said:
James Gray wrote:
I decided to just press on with my loose grasp of procs
and blocks and dive into:
"Programming Ruby:The Pragmatic Programmer's Guide, First Edition (*)
Hopefully, it'll just hit me or I'll have to find a new hobby
I suspect you may be getting a bit too obsessive about those darn' blocks
and procs. While blocks can be useful for all kinds of things, they are not
'central' to programming in Ruby. Some Ruby programmers tend to get a bit
obsessive about blocks, procs, lambda functions and the like. If you find
this stuff baffling (and unless you already have experience of a language
such as Smalltalk or Scheme in which blocks are a 'natural' part of the
language), they may initially seem very baffling indeed, my advice would be
to use blocks only where they are absolutely required - namely, for
iterating over collections of things as when, for example, iterating over
the items in an array using the each() method.
I wouldn't worry at all about using blocks as 'nameless functions' or
passing and 'yielding' them. These can be useful in certain circumstances
but then again, you could spend a lifetime doing perfectly productive
programming in Ruby without ever doing any of those things ;-)
You may perhaps find my book, The Little Book Of Ruby, of some help. This is
a free PDF book which you can download from:
www.sapphiresteel.com
While my book covers most of the essentials of Ruby - including things that
often stump newcomers (blocks, mixins etc.) I've tried to keep restrict it
to the essential details; you can also download all the source code for all
the sample programs (personally, it's my feeling that programming topics are
often easier to understand when you can try them out for yourself).
best wishes
Huw Collingbourne
http://www.sapphiresteel.com
Ruby Programming In Visual Studio 2005