# Why "::", not "."

**URL:** <https://www.ruby-forum.com/t/why-not/198095>\
**Category:** Ruby\
**Created:** [October 26, 2010, 10:47am UTC](https://www.ruby-forum.com/t/why-not/198095 "2010-10-26T10:47:52Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![Dobai-Pataky\_BSSSSl](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/d/77aa72/32.png) [@Dobai-Pataky\_BSSSSl](https://www.ruby-forum.com/u/Dobai-Pataky_BSSSSl)\
**Post date:** [October 26, 2010, 10:47am UTC](https://www.ruby-forum.com/t/why-not/198095/1 "2010-10-26T10:47:52Z")

</div>

Why does the method of modules use a dot, and the constants a double  
colon?  
e.g.  
Math::PI and Math.cos

---

<div class="post-metadata">

**Author:** ![graycardinal](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/g/54ee81/32.png) [@graycardinal](https://www.ruby-forum.com/u/graycardinal)\
**Post date:** [October 26, 2010, 11:25am UTC](https://www.ruby-forum.com/t/why-not/198095/2 "2010-10-26T11:25:16Z")

</div>

On Oct 26, 2010, at 01:48 , Oleg I. wrote:

> Why does the method of modules use a dot, and the constants a double  
> colon?  
> e.g.  
> Math::PI and Math.cos

For the same reason why inner-classes/modules use double colon, because  
they’re constants and that’s how you look up via constant namespace.

Math::PI and ActiveRecord::Base are the same type of lookup… it is  
just that Base is a module and PI is a float.

You can also use double-colon for invocation:

% ruby -e ‘p Math::exp(1)’  
2.71828182845905

but that is frowned upon as non-idiomatic ruby.

---

<div class="post-metadata">

**Author:** ![graycardinal](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/g/54ee81/32.png) [@graycardinal](https://www.ruby-forum.com/u/graycardinal)\
**Post date:** [October 26, 2010, 5:11pm UTC](https://www.ruby-forum.com/t/why-not/198095/3 "2010-10-26T17:11:02Z")

</div>

On Tue, Oct 26, 2010 at 5:24 AM, Ryan D. [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid)  
wrote:

> You can also use double-colon for invocation:
> 
> % ruby -e ‘p Math::exp(1)’  
> 2.71828182845905
> 
> but that is frowned upon as non-idiomatic ruby.

Not so much non-idiomatic as archaic.

Kind of like using thee and thou, or goeth (as in “Pride goeth before  
the fall”) in modern English.

–  
Rick DeNatale

Help fund my talk at Ruby Conf 2010:[http://pledgie.com/campaigns/13677](http://pledgie.com/campaigns/13677)  
Blog: [http://talklikeaduck.denhaven2.com/](http://talklikeaduck.denhaven2.com/)  
Github: [rubyredrick (Rick DeNatale) · GitHub](http://github.com/rubyredrick)  
Twitter: @RickDeNatale  
WWR: [NameBright - Coming Soon](http://www.workingwithrails.com/person/9021-rick-denatale)  
LinkedIn: [http://www.linkedin.com/in/rickdenatale](http://www.linkedin.com/in/rickdenatale)
