From: Brian Hartin Date: 2009-04-28T07:30:30+09:00 Subject: Why does attr_accessor in module require 'self.'? Hi there, When a class mixes in a module containing 'attr_accessor :foo', it must then use 'self.foo = ...' instead of simply 'foo = ...'. While I prefer 'self.foo' for clarity's sake, I am stumped as to _why_ this is required. For example: module A attr_accessor :a end class B include A def bar a = "bar" end def baz self.a = "baz" end end module A attr_accessor :a end class B include A def bar a = "bar" end def baz self.a = "baz" end end irb(main):050:0> b = B.new => # irb(main):051:0> b.bar => "bar" irb(main):052:0> b.a => nil irb(main):053:0> b.baz => "baz" irb(main):054:0> b.a => "baz" Does anyone know why this is? Thanks! Brian Hartin -- Posted via http://www.ruby-forum.com/.