On Tue, 15 Jun 2004 17:26:30 GMT, Sam Sungshik Kong <ssk / chol.nospam.net> wrote: > Hello! > > I am trying to understand Ruby's pure OO concept. > As my understanding is limited, my questions might seem silly...;-) > > 1. In irb, if I type self, it returns main which is type of Object. >> self > =>main >> self.class > =>Object >> main > NameError: undefined local variable or method `main' for main:Object > from (irb):28 > from :0 > > I understand that main is an instance of type Object. > Why can't I access main directly like main.something? > What *actually* is main? > A global instance? As I understand it, "main" is an object of class Object that everything outside of other class definitions belongs to, but it is not bound to a variable. The name "main" is simply the string returned by this object's "to_s" (or "inspect") method.. Tore > > 2. I heard that the top-level functions become methods of Object. > Then am I defining a class (Object)? > > If I do the following >> print "Hello" > what did I do? Am I in the Object class definition part or outside of > Object? > In other words, is the code <print "Hello"> part of Object? > If not, how is it related to main? > > Likewise, if I declare a variable on top-level, is it part of Object? > Of course, it's a global variable. > Is a global variable outside of Object class? > If so, it's not OO...? > > Well, I hope I expressed my questions well. > > Thanks in advance. > > kong > > -- Using Opera's revolutionary e-mail client: http://www.opera.com/m2/