On Aug 17, 2005, at 3:11 PM, Randy Kramer wrote:

> I'm a newbie, but I'm quite certain I've read that there is (was?) a
> difference between the two forms of block ( { } vs. ... end) with  
> respect to
> scope of variables.  Not sure where I read that, but I've been  
> doing reading
> online in many places (except the poignant guide) and dead trees Teach
> Yourself Ruby in 21 Days and the Pickaxe2.

The difference is in binding.  {...} binds tighter than do...end, so:

irb(main):001:0> puts %w{cat bat rat}.map { |w| w.capitalize }
Cat
Bat
Rat
=> nil
irb(main):002:0> puts %w{cat bat rat}.map do |w|
irb(main):003:1*   w.capitalize
irb(main):004:1> end
cat
bat
rat
=> nil

Note how the block is associated with different methods here.  Add  
parenthesis as needed.

James Edward Gray II