From: Student Jr Date: 2013-02-06T13:20:33+09:00 Subject: Re: using an instance variable inside a method The key here is "interpreter". A bare token might either be a reference to a local variable or to a method on self. The interpreter interprets the code as it is being run. When it hits a bare token, it looks for a method on self by that name. If found, it calls it. If not, it is assumed to be a local variable. And method bodies are definitely parsed ONLY when they are declared. (Do not forget that 'method =' === 'method=' in the method lookup. Note that it does NOT try method_missing. This has major implications if you are making heavy use of method_missing, as in TGWSNBN. Using self.method is considered to be really bad form, unless you are wanting method_missing to be invoked, in which case it is mandatory. You see a lot of users of TGWSNBN writing junk like that. As for attributes verses accessors, MK is doing it right. Just because o.m is defined, and o has an attribute @m, there is no particular reason to assume that o.m == o.instance_variable_get(:@m). There might be important reasons that o.m = o.instance_variable_get(:@m) * 100 or whatever. -- Posted via http://www.ruby-forum.com/.