From: "Jesús Gabriel y Galán" Date: 2013-02-06T20:39:44+09:00 Subject: Re: using an instance variable inside a method On Wed, Feb 6, 2013 at 5:20 AM, Student Jr wrote: > 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. This is not quite correct, although it's close. Running Ruby code has two steps, the parsing and the runtime. At parsing time, each token is labeled as either a local variable or a method call. If the parser has seen the token at the left hand side of an expression before, it labels it as a local variable. If not, it labels it as a method call. At runtime, tokens labeled as local variables are evaluated to their value, and token labeled as methods are looked up the method execution chain to find them. Jesus.