--0016e64cb1ea8a320804a036addf
Content-Type: text/plain; charset=ISO-8859-1

On Mon, Apr 4, 2011 at 7:12 PM, 7stud -- <bbxx789_05ss / yahoo.com> wrote:

> Josh Cheek wrote in post #990762:
> >
> > 3) For some reason that I don't know (probably interpreter magic) an
> > uninitialized variable can be referenced in a boolean equation and it
> > will
> > evaluate to nil.
> >
> > first_name  irst_name || "" # ""
> > first_name  josh"
> > first_name  irst_name || "" # "josh"
> >
> >
> > So, it will set the variable to the empty string, if the variable is
> > undeclared, or false , or nil.
>
> I think the story goes something like this:  when the parser sees any
> 'name expression, name gets entered into the symbol table.
> Thereafter, you will no longer get an exception when referencing the
> variable.  In your code, the parser sees 'first_name  so first_name
> is entered into the symbol table, and then when ruby executes your code,
> the expression on the right hand side of the equals sign is executed.
>
>
Actually, I was thinking about it, and this contradicts that a||xpands
to a||a

undefined1 || defined
undefined1 # :defined

undefined2   undefined2 || :defined )
undefined2 # :defined

undefined3 || ( undefined3  defined )
undefined3 # # ~> -:7:in `<main>': undefined local variable or method `undefined3' for
main:Object (NameError)

--0016e64cb1ea8a320804a036addf--