[LRUG] attr_accessor parsed as a method variable when setting with a get

Tom Stuart tom at experthuman.com
Wed Sep 21 02:57:09 PDT 2011


On 21 Sep 2011, at 10:50, James Darling wrote:
> It seems that on line 9, the second use of the configuration getter method call is being parsed as a method variable, which is nil as it isn't set. You can work around this by explicitly saying this.configuration or configuration(), but it certainly doesn't behave as you would expect.

You do just have to say "self.configuration =" if you want Ruby to treat it as a call to #configuration= rather than an assignment to a local variable called "configuration". This is a quirk of the way Ruby decides, syntactically, what the local variables are (roughly: by looking for things that look like assignments).

Cheers,
-Tom


More information about the Chat mailing list