Sebastian Hungerecker
2/18/2008 12:41:00 PM
ruud wrote:
> Most of the time I find a class.var notation of a class::var notation.
That's not entirely accurate. There is no class.var. There's object.method
(where object can be a class and the method can have the same name as a
variable, but it still has to be a method) and there's namespace::Constant
where namespace can be a class or a module and Constant has to be a constant
(it can't be any other sort of variable).
The :: is for accessing constants in a namespace and the . is for calling
methods on an object.
It is not possible to access non-constant variables from outside the class
without using methods designed for that purpose.
> In documentation I find class#method notation. How are these three
> related to each other?
class#method describes an instance method (as opposed to class.method which
would describe a class method). If you see something like String#length, that
means that you could e.g. write "hello".length, but not String.length. If you
see String.new, you have to actually type String.new and not something
like "hello".new.
HTH,
Sebastian
--
Jabber: sepp2k@jabber.org
ICQ: 205544826