Module as namespace

Hi:

I was wondering, is there a difference between the following
two definitions of class C?

module Fred; end
class Fred::C; end

or

module Fred
class C
end
end

They seem equivalent to me.

c = Fred::C.new

···


Jim Freeze

Hi,

I was wondering, is there a difference between the following
two definitions of class C?

module Fred; end
class Fred::C; end

or

module Fred
class C
end
end

In the former case, a constant defined in Fred can not be
accessed from C. Equivalent for other points.

module Fred; A = 1; end
class Fred::C
p A # => error
end
module Fred
class C
p A # => ok, prints 1
end
end

···

At Tue, 6 May 2003 21:41:20 +0900, Jim Freeze wrote:


Nobu Nakada