From: Eric Schwartz Date: 2002-11-12T04:46:43+09:00 Subject: More fun with modules Okay, I *thought* I understood modules. Then I try to factor out some common 'utility' methods into a separate file so that I don't have to mock up some silly inheritance hierarchy just to share functions like AddHref(below). But apparently I don't understand how names propogate. I figured that inside TestHarness::Bah, if it couldn't resolve the name in Bah, it would look next in TestHarness, and then in the global namespace. Did I err? If so, how can I get what I want? Do I need to introduce an artificial inheritance here, or is there a way I'm not seeing to share the code? Thanks, -=Eric $ cat testharness.rb module TestHarness def AddHref(url, text) "#{text}" end end $ cat testview.rb require 'testharness' module TestHarness class Bah def myprint puts AddHref('http://www.google.com/', 'Google') end end end TestHarness::Bah.new.myprint $ ruby testview.rb testview.rb:6: in 'myprint': undefined method 'AddHref' for # (NameError) from testview.rb:11 -=Eric -- Come to think of it, there are already a million monkeys on a million typewriters, and Usenet is NOTHING like Shakespeare. -- Blair Houghton