From: Tim Hunter Date: 2008-01-02T07:53:24+09:00 Subject: Re: another newbie question K�sa M�rton wrote: > Hi group, > > I apologize for the newbie question. > > Is there in Ruby some possibility for making global > variables visible from within a DEF, except that > passing all of them as parameters? > > E.g.: > > class class1 > ... > def some_method > ... > end > end > > ... > g = class1.new > ... > > > def f(g) <--- i'd like to avoid to pass g here > ... > g.some_method > ... > end > > I have not found any other solution in the documentation. > When the number of these global objects become large (e.g. >20), > passing all of them each time becomes incomfortable. > Any help appreciated. > > Marton > > Variables with names that start with $ are global. $g = class1.new Bear in mind that using global variables is often considered bad form because in large programs it is hard to figure out where the variable is used and modified. If your program relies on a lot of global variables you might consider re-thinking how your program works. Whatever you decide to do, good luck! -- RMagick: http://rmagick.rubyforge.org/ RMagick 2: http://rmagick.rubyforge.org/rmagick2.html