TypeError: can't make subclass of Class

Why can’t a class be an instance of class Class and also inherit from
class Class in ruby?

Let’s say I defined a singleton method on Class:

1.9.3p0 :032 > class Class
1.9.3p0 :033?> def Class.class_singleton
1.9.3p0 :034?> puts ‘class singleton’
1.9.3p0 :035?> end
1.9.3p0 :036?> end

And I want to create a class that can inherit that singleton method:

1.9.3p0 :039 > class Q < Class
1.9.3p0 :040?> end
TypeError: can’t make subclass of Class

How then could it be possible to access that singleton method without
directly calling it on Class? And why is inheriting from Class not
allowed?

This forum is not affiliated to the Ruby language, Ruby on Rails framework, nor any Ruby applications discussed here.

| Privacy Policy | Terms of Service | Remote Ruby Jobs