Forum: Ruby Problem with Module/Class name resolution

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.
7768bb3b0b4bf849895e50ba2e5f68cb?d=identicon&s=25 Thomas Leitner (Guest)
on 2007-02-19 17:06
(Received via mailing list)
Hi,

consider the following:

module A
  X = 1
end

p A::X              # => 1

module B
  include A
end

p B::X              # => 1

module A
  module Help
    p X             # => 1
  end
end

module B
  module Help
    p X              # => NameError: uninitialized constant B::Help::X
  end
end


Why does referencing X from A, B, and A::Help work but not from
B::Help although A is included in B? Is there a work-around to make
this work?

Bye,
  Thomas
This topic is locked and can not be replied to.