Hi --

On Tue, 30 Jun 2009, Wijnand Wiersma wrote:

> Hi all,
>
> It seems writer methods don't work within blocks, the names are resolved to 
> new local variable names I guess.
> It is funny however the reader method does seem to work fine.
> Is it possible to make it work anyway  without changing the syntax within the 
> block?

It's not a block thing. Writer methods always need an explicit
receiver. You always have to write:

   obj.x = y

because the parser always sees this:

   x = y

as a local variable assignment, even if there's a method around called
x=.


David

-- 
David A. Black / Ruby Power and Light, LLC
Ruby/Rails consulting & training: http://www.rubypal.com
Now available: The Well-Grounded Rubyist (http://manning.com/black2)
"Ruby 1.9: What You Need To Know" Envycasts with David A. Black
http://www.envycasts.com