From: ptkwt@...1.aracnet.com (Phil Tomson) Date: 2003-04-09T16:58:02+09:00 Subject: Re: instance_variable_set question In article , Dave Thomas wrote: > >On Tuesday, April 8, 2003, at 03:12 PM, Chris Pine wrote: > >> Hello, >> >> Is this how this is supposed to work? >> >> >> irb(main):001:0> class Foo; end >> => nil >> irb(main):002:0> foo = Foo.new >> => # >> irb(main):003:0> foo.instance_variable_set :bar, 15 >> NameError: `bar' is not an instance variable name >> from (irb):3:in `instance_variable_set' >> from (irb):3 >> > >But the instance variable would be called :@bar :) > It _is_ a bit confusing, though - if you made an attr_accessor for @bar, you refer to it as :bar, not :@bar : class Foo attr_accessor :bar #not :@bar end Phil