From: James Edward Gray II Date: 2007-04-04T22:37:45+09:00 Subject: Re: Everything is a object? On Apr 4, 2007, at 8:30 AM, tsela.cg@gmail.com wrote: > No. "attr_accessor" only defines two instance methods within the class > you're using it in, which allow @var (which is a private instance > variable) to be accessible from outside its object. In other words, > > class SomeClass > > attr_accessor :var > > end > > is exactly equivalent to: > > class SomeClass > > def var > @var > end > > def var=(param) > @var = param > end > end Not "exactly equivalent." It also silences the warning: $ ruby -we 'class Test; def var; @var; end; end; p Test.new.var' -e:1: warning: instance variable @var not initialized nil $ ruby -we 'class Test; attr_reader :var; end; p Test.new.var' nil James Edward Gray II