From: Daniel Schierbeck Date: 2005-12-01T05:37:30+09:00 Subject: Re: Dumb question: in documentation, why Object#method, and not Object.method ? David A. Black wrote: > Hi -- > > On Thu, 1 Dec 2005, Marcel Molina Jr. wrote: > >> On Thu, Dec 01, 2005 at 04:17:30AM +0900, Elf M. Sternberg wrote: >>> I keep seeing this syntax in documentation: Object#method, but in actual >>> use sending a message to an object is usually >>> >>> object = Object.new >>> object.method >>> >>> Is this just to emphasize that method() operates on an instance of >>> Object and not the class Object? >> >> The # is a naming convention. >> >> Class#method means method is an instance method. >> Class::method means method is a class method. >> >> For example, do >> >> ri IO.read >> >> There is IO::read and IO#read. > > Interesting -- I never picked up on ri's use of :: in preference to > the dot. I personally use Class.method for class methods (indeed for > any singleton method). I believe that to be the convention, too. Klass.method <- Class method Klass#method <- Instance method Klass::FOO <- Class constant Klass::AnotherKlass <- Class constant (class or module)