From: Eric Christopherson Date: 2010-04-01T08:50:14+09:00 Subject: Re: Post-Condition if Statements And NameErrors On Wed, Mar 31, 2010 at 4:05 PM, MaggotChild wrote: > I thought this was odd: > > def bs >  1 > end > >  print y + 1 if y = bs > > NameError: undefined local variable or method `y' for main:Object > > And, of course, the multi-line if works: > > if x = bs >  print x + 1 > end Something like this came up a few weeks ago. I think the parser is the one generating the NameError, because the parser only consider a variable to be defined if it sees an assignment to it, and such assignment has to come *before* any use of the variable. Even though the interpreter actually would actually execute y = bs first, the parser doesn't see it at the point where its value is used.