Why "::", not "."

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

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.

On Tue, Oct 26, 2010 at 5:24 AM, Ryan D. [email protected]
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
Blog: http://talklikeaduck.denhaven2.com/
Github: rubyredrick (Rick DeNatale) · GitHub
Twitter: @RickDeNatale
WWR: http://www.workingwithrails.com/person/9021-rick-denatale
LinkedIn: http://www.linkedin.com/in/rickdenatale