On Tue, Apr 5, 2011 at 4:35 PM, Chad Perrin <code / apotheon.net> wrote: > On Tue, Apr 05, 2011 at 12:30:47PM +0900, Josh Cheek wrote: >> On Mon, Apr 4, 2011 at 7:12 PM, 7stud -- <bbxx789_05ss / yahoo.com> >> wrote: >> > >> > Here is an example that might prove illustrative: >> > >> > if 1 > 10 >> > ¨Β §θεμμοξεφεεψεγυτεσ >> > 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. From the line where an assignment to a identifier is found this identifier denotes a local variable - whether the code is actually executed does not matter. This is only about syntactical order. Consider $ ruby19 -e 'puts(x) if x=1' -e:1: warning: found = in conditional, should be == -e:1:in `<main>': undefined local variable or method `x' for main:Object (NameError) $ ruby19 -e 'x=1;puts(x) if x' 1 $ Kind regards robert -- remember.guy do |as, often| as.you_can - without end http://blog.rubybestpractices.com/