Hi,

Am Dienstag, 30. Jun 2009, 03:44:48 +0900 schrieb Wijnand Wiersma:
> 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?
>
> My example gist: http://gist.github.com/137741

You don't even need an instance_eval. It won't work in a module
definition either:

  module M
    class <<self
      def x= val
        puts "Hi, here is C.x=(#{val.inspect})."
        @x = val
      end
    end
    @x     = "X0"
    x      = "X1"
    self.x = "X2"
  end

Maybe you prefer the self.-construction. I surely don't.

Bertram


-- 
Bertram Scharpf
Stuttgart, Deutschland/Germany
http://www.bertram-scharpf.de