From: Kevin Bullock Date: 2004-06-19T07:56:23+09:00 Subject: Re: a newbie question about main, Object... On Jun 18, 2004, at 1:43 PM, Sam Sungshik Kong wrote: > Excellent explanation, Kevin! Glad I could help. > Kevin, what is the right way to think about a global variable? > In pure OO, there's no real global variable, right? > Then, is it against OO? There's likely to be differing opinions on this matter. I don't think it's necessarily against good object-oriented style to have global variables available in a language. This seems to fit in well with Ruby's approach to interacting very easily with the surrounding system, but still having everything be an object. Ruby preserves information hiding and encapsulation for the general case, as one would expect, and chooses to also allow some variables to be globally accessible. They're seldom used and declared differently, which seems to discourage using them in places they're not meant to be. There is an argument to be made, though, that allowing global variables does in fact break information hiding, and I have some affinity for that argument as well. But in practice, having globals is useful for covering Perl's problem space with Ruby, even if you never use them when covering Java's problem space. Pacem in terris / Mir / Shanti / Salaam / Heiwa Kevin R. Bullock