To expand on the nice diagnostic suggestion in the foregoing post, x and
@x are not the same variable, and they do not have the same scope.

If your program consists entirely of this code:

   @x = 'hello'
   def printMe
     puts x
     puts @x
   end

@x is an instance variable of self (the Object instance that is your
program). It is visible to all methods of self.

printMe() is a method you've added to self. It can see the value of @x.

x is a local variable whose scope is limited to printMe(), and is
undefined.

(That, at any rate, is how I understand it.)

-- 
Posted via http://www.ruby-forum.com/.