Re: Need help understanding namespace rules-modules and clas


#1

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