Eric MSP Veith wrote:
> what's the difference between:
> 
> - ---%<---
> namespace A

you mean 'module A' ?

>   class B
>     def foo
>       # ...
>     end
>   end
> end
> - --->%---
> 
> and
> 
> - ---%<---
> class C
>   def bar
>     # ...
>   end
> end
> - --->%---
> 
> Besindes, of course, the naming (A::B vs C)?

That's the main difference. Constant lookups are modified, e.g. 
referring to 'D' inside B will look for A::B::D, A::D or ::D in that 
order (I believe)

This can lead to some confusing errors, e.g.

module A
  class B
    def bar
      Socket.new('127.0.0.1',80)
    end
  end
end
A::B.new.bar  # uninitialized constant A::B::Socket (NameError)

when actually the problem is that you forgot to "require 'socket'"
-- 
Posted via http://www.ruby-forum.com/.