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?
on 2012-10-06 20:16
Please log in before posting. Registration is free and takes only a minute.
Existing account
(Switch to SSL-encrypted connection)
NEW: Do you have a Google/GoogleMail or Yahoo account? No registration required!
Log in with Google account | Log in with Yahoo account
Log in with Google account | Log in with Yahoo account
No account? Register here.