S
Sam Sungshik Kong
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.
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?
2. I heard that the top-level functions become methods of Object.
Then am I defining a class (Object)?
If I do the following
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
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.
NameError: undefined local variable or method `main' for main:Objectself =>main
=>Object
main
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?
2. I heard that the top-level functions become methods of Object.
Then am I defining a class (Object)?
If I do the following
what did I do? Am I in the Object class definition part or outside ofprint "Hello"
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