From: Mike Depot Date: 2002-06-01T05:17:27+09:00 Subject: Singleton Waring - Mixins & Inheretance When I run the test script below, I get the following warning: (eval):4: warning: instance variable @__instance__ not initialized After playing around with it a bit, I noticed that including Singleton in MyDerivedClass eliminates the warning. The code seems to function properly either way. If I mixin module A into class B, and then define class C as inherited from class B, do I have to explicitly mixin A into class C? Is this something to do with the way mixins get inhereted into subclasses, or am I just doing something else wrong entirely? #!/usr/bin/ruby -w require 'singleton' class MyBaseClass include Singleton attr_accessor :x def initialize @x = 'Hello' end; end class MyDerivedClass < MyBaseClass # include Singleton # do i need this? attr_accessor :y def initialize super @y = 'World' end; end a = MyDerivedClass.instance; b = MyDerivedClass.instance; p a.x p a.y a.x = "Hi" a.y = "There" p a.x p a.y p b.x p b.y