[LRUG] attr_accessor parsed as a method variable when setting with a get
Tom Stuart
tom at experthuman.com
Wed Sep 21 03:31:12 PDT 2011
On 21 Sep 2011, at 11:24, Paul Robinson wrote:
> On 21 Sep 2011, at 11:17, Max Williams wrote:
>> self.configuration is also more readable, ie more obviously a method call.
> Yes, but "configuration" in this scenario is not a method. It's an instance variable. @configuration is the right syntax for referencing it.
A question of taste. If I've defined public accessors, my preference is to use them even within methods of that object, rather than touching the instance variable directly. I like this because a) it encapsulates access to that piece of state, in case I want to provide a default or otherwise wrap reads/writes to the instance variable, and b) instance variables are ugly innit.
But if you like reading/writing instance variables in your methods, perhaps for Nebulous Performance Reasons, that's fine too.
Cheers,
-Tom
More information about the Chat
mailing list