From: "Hal E. Fulton" Date: 2003-05-09T07:52:25+09:00 Subject: Re: Can a global be a constant? ----- Original Message ----- From: "Brian Candler" To: "ruby-talk ML" Sent: Thursday, May 08, 2003 5:44 PM Subject: Re: Can a global be a constant? > On Fri, May 09, 2003 at 07:04:40AM +0900, Jim Freeze wrote: > > Ok. I didn't realize that $, @, and @@ were considered part > > of the name. Makes sense now. > > And you'll see this if you try to access one of these things using the > symbol: > > class Foo; end > a = Foo.new > a.instance_variable_set(:@bar,1) #>> OK > a.instance_variable_set(:bar,1) #>> NameError: 'bar' is not an > instance variable name Yet this is potentially confusing, because a line like attr_accessor :foo does create an accessor for @foo. I suppose the rationale is that you're specifying the symbol corresponding to the method name rather than the instance variable. Hal