Also, when I said that they were "approximately" the same, there are a
few exceptions, though you should rarely if ever encounter them if you
stick to Ruby's conventions. One example of a difference between
"M::(...)" and "M.(...)":

==== begin snippet ====
module M
  def self.Foo; "foo"; end
  module Foo; end
end

M::Foo
# => M::Foo

M.Foo
# => "foo"
==== end snippet ====

The reason you should never encounter this is because it's considered
a violation of the conventions if you don't start methods with a
lowercase letter. That's why we can safely stick to "M::(...)" for
referencing namespaces created by methods or classes, and "M.(...)"
for invoking methods.
--
John Feminella
Principal Consultant, BitsBuilder
LI: http://www.linkedin.com/in/johnxf
SO: http://stackoverflow.com/users/75170/



On Sun, Jun 5, 2011 at 08:54, John Feminella <johnf / bitsbuilder.com> wrote:
> In the case of a method they're approximately the same:
>
> ==== begin snippet ====
> module M
> def self.foo; "foo"; end
> end
>
> M.foo
> # => "foo"
>
> M::foo
> # => "foo"
> ==== end snippet ====
>
> But sometimes you want to access _constants_, not methods. Then
> they're drastically different:
>
> ==== begin snippet ====
> module M
> module Inner; end
> end
>
> M::Inner
> # => M::Inner
>
> M.Inner
> # => NoMethodError: undefined method `Inner' for M:Module
> ==== end snippet ====
> --
> John Feminella
> Principal Consultant, BitsBuilder
> LI: http://www.linkedin.com/in/johnxf
> SO: http://stackoverflow.com/users/75170/
>