i.e.
MyClass.myproc
MyClass#myproc
MyClass::myproc
What's the difference?
MyClass::myproc -- myproc is a class method, called either of these two
ways:
MyClass::myproc
MyClass.myproc
MyClass#myproc -- myproc is an instance method, belonging to instances
of MyClass:
my_obj = MyClass.new
my_obj.myproc
MyClass.myproc probably means the same as MyClass::myproc.
Cheers,
Dave
But, if you change myproc to Myproc, there is a difference. Ruby will
assume that MyClass::Myproc is an attempt to access a constant, and
that MyClass.Myproc, MyClass.Myproc(), and MyClass::Myproc() are
method invocations.
HTH,
Jim
No a guru, but trying to post my first answer here:
MyClass.myproc
is a call to the class method myproc of class MyClass.
MyClass#myproc
does not exist in the syntax, but is used in Ruby
documentation to differentiate the call of an
instance method from the call of a class method.
In fact it means MyClass.new.myproc or more generic
myInstance.myproc where myInstance is an instance
of MyClass.
MyClass::myproc
means the function or method myproc in the name space
MyClass. MyClass could be a class context or a module
or whatsoever.
Michael, thanks for explaining that # was only a documentation aide.
To me that was sort of a pitfall.