Forum: Ruby Re: Need help understanding namespace rules-modules and clas

Announcement (2017-05-07): www.ruby-forum.com is now read-only since I unfortunately do not have the time to support and maintain the forum any more. Please see rubyonrails.org/community and ruby-lang.org/en/community for other Rails- und Ruby-related community platforms.
DEBAUN, STEVE [AG-Contractor/2400] (Guest)
on 2006-05-17 02:28
(Received via mailing list)
Ooh, ooh, I can do this one!!11!11

'some_file.rb'
module Foo
	class Baz
		def woot; 'hello I am in Foo'; end
	end
end

'some_other_file.rb'
module Bar
	class Baz
		def woot; 'hello I am in Bar'; end
	end
	class Pork
		def woot
			b = Baz.new # refers to Bar::Baz
			b2 = Foo::Baz.new # refers to the other Baz
		end
	end
end

'my_file.rb'
require 'some_file'
require 'some_other_file'
fb = Foo::Baz.new
bb = Bar::Baz.new
This topic is locked and can not be replied to.