From: Alan Chen Date: 2002-08-08T04:17:17+09:00 Subject: Inherited question I'm playing around with the inherited hook and I'm having some problems. The following code is running on "ruby 1.6.7 (2002-03-19) [i386-linux]". It works fine when I leave the inherited def out, and explicitly register the child class. However, if I attempt the same with the hook, I get the following error: check-inherited.rb:9:in `initialize': wrong # of arguments(0 for 1) (ArgumentError) from check-inherited.rb:9:in `new' from check-inherited.rb:9:in `register' from check-inherited.rb:5:in `inherited' from check-inherited.rb:20 ### check-inherited.rb class Base @@childitems = {} # def self.inherited(subclass) # self.register(subclass) # end def self.register(subclass) item = subclass.new @@childitems[item.name] = item end attr_reader :name def initialize(name) @name = name end end class Sub1 < Base def initialize super('child_sub1') end end # not called when testing with self.inherited commented-in Base.register(Sub1) ### end of file -- Alan Chen Digikata LLC http://digikata.com