On 8/16/06, Huw Collingbourne <huw / delthisbitdarkneon.com> wrote: > > "He Fa" <hfashina / hotmail.com> wrote in message > news:7d906db0cf97f3b16d1da58da69f53f6 / example.com... > > 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. > Ruby's standard library is filled with methods that (often optionally) take blocks as arguments. Ignoring them isn't gonna do you any good. A closure is a function that remembers the environment it was defined in, and if you don't understand the concept of a function, programming is not for you. > 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 ;-) > Ignoring closures, which are extensively used within Ruby's standard library and a large part in what makes the language so good for many tasks, is not going to do you any good at all. > 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 > > > > -- - Simen