From: Jeremy Bopp Date: 2010-10-07T12:47:46+09:00 Subject: Re: Missing @ for instace variable in class, but no error message On 10/06/2010 10:17 PM, John Sikora wrote: > Jeremy Bopp wrote: >> Beware of attempting to use the bare a= accessor within an instance >> method though. That will instead cause a variable named "a" to be >> created with the the method's scope rather than use the a= accessor, so >> @a won't be updated as expected. If you want to use the a= accessor, >> you need to use self.a = whatever. e.g.: >> > > Jeremy raises an excellent point. I wish I had read this post a few days > ago. A few weeks ago, someone asked the question (paraphrased) "why do > people use 'self.some_method' instead of just 'some_method'?". > > I knew that I had a lot of redundant 'self's and a few days ago I got > around to removing them in a script. As Jeremy points out, leaving off > 'self' in 'some_method=' results in the creation of the variable > 'some_method', as testing showed. Thanks go to Dave Thomas, Chad Fowler, Andy Hunt, and their book "Programming Ruby" -- my introduction to Ruby. :-) -Jeremy