From: 7stud -- Date: 2011-04-05T09:12:07+09:00 Subject: Re: pipe question 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 = first_name || "" # => "" > first_name = "josh" > first_name = first_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. 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) -- Posted via http://www.ruby-forum.com/.