On Dec 10, 2005, at 8:34 PM, jonathan wrote: > Hmm. Ok, so there really is no singleton class for Myclass? In other > words, must the singleton always be associated with an instance and > not > a class? In Ruby, a class *is* an instance. Specifically, a class is an instance of the class Class. So, yes, you can reference the singleton object of a class: class <<Array end More often it is done like this though: class Array class <<self # instance methods defined here will be # for the object Array (which happens to be a class) # so these methods become 'class methods' for Array end end Alternatively you can do it like this: def Array.class_method1 # an instance specific method # in this case the instance is the class object Array end > Yea. That is cool, but can you still do something like this: > > class Myclass > end > > def extend_class( some_class ) > code = %{ class #{some_class.class}_extension < #{some_class.class} > def new_method1 > end > ... > end } > eval( code ) > > extend_class( Myclass ) > x = Myclass_extension.new > x.new_method1 > y = Myclass_extension.new > y.new_method1 I'm not sure what you are getting at here. Myclass.class is the particular object Class. Because all class objects are instances of Class. #{some_class.class}_extension ends up being the string Class_extension because Class.to_s is the string 'Class'. If you want to subclass and add methods just do it: class Myclass end class Subclass < Myclass def new_method1 end end x = Subclass.new y = Subclass.new x.new_method1 y.new_method1