From: dblack@... Date: 2006-07-12T02:00:24+09:00 Subject: Re: blocks and procs Hi -- On Wed, 12 Jul 2006, Dark Ambient wrote: > Just curious, I'm just learning about Procs, and have already looked at > using blocks. > Are they very close in the way they function. It seems that way to me. > Perhaps I'm wrong. > Is one favoured above the other ? They're different things. A block is a syntactic construct, part of a method call. A Proc object is an object. They are, however, closely related. Using special argument syntax, a method can turn the block supplied to it into a Proc: def meth(&block) # block is the Proc version of the block block.call # etc. end meth { # this is the block } Also, you can use Proc objects as block substitutes: meth &some_proc_object David -- http://www.rubypowerandlight.com => Ruby/Rails training & consultancy http://www.manning.com/black => RUBY FOR RAILS, the Ruby book for Rails developers http://dablog.rubypal.com => D[avid ]A[. ]B[lack's][ Web]log dblack@wobblini.net => me