Can somebody point me to an *accurate* list of the rules for constant
lookup?
I've just been caught out by the following.
==> works.rb <==
module Foo
class Bar; end
class Baz
def initialize
@bar = Bar.new
end
end
end
Foo::Baz.new
==> broken.rb <==
module Foo
class Bar; end
end
class Foo::Baz
def initialize
@bar = Bar.new
end
end
Foo::Baz.new
In both cases there is a module Foo, a class Foo::Bar and a class
Foo::Baz. The only difference between the two is that one uses "module
Foo; class Baz" and the second uses "class Foo::Baz"
I thought the two were identical if module Foo already exists, but
clearly I was mistaken.
Regards,
Brian.
···
--
Posted via http://www.ruby-forum.com/.