Singleton class of singleton class of BasicObject in Ruby


Singleton class of singleton class of BasicObject in Ruby



This is mostly an "academic" one but here it goes:



According to the ruby eigenclass diagram (slightly edited) here:



enter image description here



BasicObject.singleton_class.singleton_class.superclass is Class.


BasicObject.singleton_class.singleton_class.superclass


Class



However running this on a ruby interpreter it turns out that BasicObject.singleton_class.singleton_class.superclass is #Class and not Class. Therefore, is the diagram lying or am I missing something?


BasicObject.singleton_class.singleton_class.superclass


#Class


Class



Thanks.





BasicObject.singleton_class.singleton_class.is_a?(Class) #⇒ true #Class is a string representation.
– mudasobwa
Jul 2 at 8:59


BasicObject.singleton_class.singleton_class.is_a?(Class) #⇒ true


#Class





Your question says BasicObject.singleton_class.singleton_class but your diagram says BasicObject.singleton_class.singleton_class.superclass. Please clarify.
– Stefan
Jul 2 at 9:02


BasicObject.singleton_class.singleton_class


BasicObject.singleton_class.singleton_class.superclass





@Stefan @mudasobwa You are right. I meant to say BasicObject.singleton_class.singleton_class.superclass. I also edited the question. Any clues are more than welcome.
– kstratis
Jul 2 at 9:18



BasicObject.singleton_class.singleton_class.superclass





@kstratis: not sure what confusion is still there after mudasobwa's clarification. It IS a Class.
– Sergio Tulentsev
Jul 2 at 9:37





I like your train of thought. This COULD be true. Maybe it was accurate at the time. On the other hand I haven't heard of any object model changes in Ruby in recent years. Anyway to tell you the truth I don't remember. It was months ago. I'll try to ping a moderator at the IRC and will update the post in case of any updates. Thanks for the help anyway.
– kstratis
Jul 2 at 9:53









By clicking "Post Your Answer", you acknowledge that you have read our updated terms of service, privacy policy and cookie policy, and that your continued use of the website is subject to these policies.

Popular posts from this blog

Rothschild family

Cinema of Italy