[lnkForumImage]
TotalShareware - Download Free Software

Confronta i prezzi di migliaia di prodotti.
Asp Forum
 Home | Login | Register | Search 


 

Forums >

comp.lang.ruby

Double colon in class definition?

Robert La ferla

6/29/2007 3:02:00 AM

What does the double colon mean in a class definition. e.g.
ActiveRecord::Base ? I couldn't locate it in the docs. I suspect
it's akin to a category or a namespace. The only documentation on
double-colon that I have found indicates that "::" is used to make
class methods easier to read since "." will also call a class method.


1 Answer

yermej

6/29/2007 4:22:00 AM

0

On Jun 28, 10:02 pm, Robert La Ferla <robertlafe...@comcast.net>
wrote:
> What does the double colon mean in a class definition. e.g.
> ActiveRecord::Base ? I couldn't locate it in the docs. I suspect
> it's akin to a category or a namespace. The only documentation on
> double-colon that I have found indicates that "::" is used to make
> class methods easier to read since "." will also call a class method.

In this case, it indicates that Base is a class within the
ActiveRecord module. More generally, it's used to reference a constant
(modules & classes are constants) within a module (similar to a
namespace) or a class. As in:

irb> Object::Fixnum.class
=> Class
irb> Object::RUBY_VERSION.class
=> String