From: "Jesús Gabriel y Galán" Date: 2011-04-06T16:00:08+09:00 Subject: Re: pipe question On Tue, Apr 5, 2011 at 4:35 PM, Chad Perrin wrote: > On Tue, Apr 05, 2011 at 12:30:47PM +0900, Josh Cheek wrote: >> On Mon, Apr 4, 2011 at 7:12 PM, 7stud -- >> wrote: >> > >> > Here is an example that might prove illustrative: >> > >> > if 1 > 10 >> >  x = 'hello'  #never executes >> > end >> > >> > puts x  #=> nil >> > puts y  #=> undefined local variable or method `y' >> >        #for main:Object (NameError) >> >> Good thought. I'm honestly surprised that works! I guess it must add x >> to the symbol table at parse time. > > Is that something we should be able to depend on, though -- or just an > accident of implementation? I think it's a language feature. In the Ruby Draft Specification (http://ruby-std.netlab.jp/draft_spec/draft_ruby_spec-20091201-hl.pdf) you can read this: 9.1.2 References to local variables An occurrence of a local-variable-identifier can be a reference to a local variable or a method invocation. In order to determine whether the occurrence of a local-variable-identifier is a reference to a local variable or a method invocation, before the evaluation of a local variable scope, the scope is scanned sequentially for local-variable-identifier s. For each occurrence of a local-variable-identifier I, take the following steps: a) If I occurs in one of the forms below, I is a reference to a local variable. 1 ˆ mandatory-parameter 2 ˆ optional-parameter-name 3 ˆ array-parameter-name 4 ˆ block-parameter-name 5 ˆ variable of left-hand-side 6 ˆ variable of single-variable-assignment-expression 7 ˆ variable of single-variable-assignment-statement 8 ˆ variable of abbreviated-variable-assignment-expression 9 ˆ variable of abbreviated-variable-assignment-statement As you can see, number 5 (variable of LHS) covers the case we are discussing here. Jesus.