From: Eric Hodel Date: 2005-10-28T13:45:18+09:00 Subject: Re: Stuck with modules/classes/inheritance On Oct 27, 2005, at 9:35 PM, Kev Jackson wrote: > given: > > test.rb : > > require 'b' > > b = B.new b = A::B.new > lib/base.rb: > > module A > class Base > end > end > > lib/b.rb: require 'base' > module A > class B < Base > end > end > > Why do I get > > ./lib/b.rb:2: uninitialized constant A::Base (NameError) > from test.rb:1:in `require' > from test.rb:1 > > ? > > This is a stripped down version of what I want to do (ie organize > my code into a module, but still keep classes in separate files, > have a base class and inherit). > > It's probably something trivial, but at the moment I'm stuck - any > help would be (as always) greatly appreciated Also you can get away with less indentation: $ cat base.rb module A; end class A::Base end $ cat b.rb require 'base' class A::B < A::Base end -- Eric Hodel - drbrain@segment7.net - http://segment7.net FEC2 57F1 D465 EB15 5D6E 7C11 332A 551C 796C 9F04