Why "::", not "."

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

···

--
Posted via http://www.ruby-forum.com/.

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 Oct 26, 2010, at 01:48 , Oleg Igor wrote:

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

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. <G>

···

On Tue, Oct 26, 2010 at 5:24 AM, Ryan Davis <ryand-ruby@zenspider.com> 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.

--
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