On 2004 Apr 13, at 17:14, Jeff Massung wrote: > I noticed that if I have a global variable: > > x = 10 > > In some function: > > def show_x > print x > end > > This fails (unknown local x). But if I use @x in both cases it works > just > fine. Can someone explain this to me? Also, what about @@ variables? > Likewise, is there @@@ or @@@@ ? The @ prefix marks an instance variable, which is global to the instance of the class you're in. Ruby's a very object-oriented language. If you don't think you're in an class, then you're scoped in the default top-level class. So your @x is an instance variable for this top-level class. @@ is a class variable, available to all instances of that class. It will seem to work like @ in the top-level scope. Check out http://www.rubycentral.com/book/tut_classes.html for a much better rundown of this stuff. -- Ryan "John" Platte Custom services, NIKA Consulting http://nikaconsulting.com/