From: psy Date: 2008-08-18T17:03:16+09:00 Subject: Re: What's difference? Hier from Programming Ruby book. Its not exactly for this case, but i think it gets close : ---- When Ruby sees a name such as ``a'' in an expression, it needs to determine if it is a local variable reference or a call to a method with no parameters. To decide which is the case, Ruby uses a heuristic. As Ruby reads a source file, it keeps track of symbols that have been assigned to. It assumes that these symbols are variables. When it subsequently comes across a symbol that might be either a variable or a method call, it checks to see if it has seen a prior assignment to that symbol. If so, it treats the symbol as a variable; otherwise it treats it as a method call. ---- There is also this example down below : ---- Note that the assignment does not have to be executed---Ruby just has to have seen it. This program does not raise an error. a = 1 if false; a ---- Greets On Mon, 18 Aug 2008 15:29:04 +0900 Kyung won Cheon wrote: > --- test1.rb --- > > b = 1 > puts a if a = b > > # NameError: undefined local variable or method `a' for main:Object > > > --- test2.rb --- > > a = 1 if false > puts defined?(a) > > # local-variable > > > ############### > # Help Me^^ > ###############