From: "Florian Groß" Date: 2005-04-20T00:29:34+09:00 Subject: Re: - E03c - The Ruby Object Model (Revised Documentation) Ilias Lazaridis wrote: > see my reply to Mr. Matsumoto: > > "class Object inherits from nothing (represented by object nil)" > > new diagramm: > > http://lazaridis.com/case/lang/ruby/ Why is it so hard to say "doesn't inherit" instead of "inherits from non-existent"? Expertise isn't making things looking more complex than they are -- it is making them as simple as possible, but not any simpler. Just remove clutter that doesn't matter and you will end up with a diagram that is more clear and easier to understand. I'm not sure what you mean by the term 'singleton instance' -- classes are instances of Class. Whenever you see something like 'foobars' you can transform that to 'instances of Foobar' mentally. What Ruby's singleton classes do is providing a way of treating a single Object as if it had a class by itself that nobody else uses. Here is an example: obj = "hello world" def obj.reverse() "fake reverse" end obj.reverse # => "fake reverse" "foobar".reverse # => "raboof" Which is equivalent to this: obj = "hello world" class << obj # enter singleton class def reverse() "fake reverse" end end # exit singleton class obj.reverse # => "fake reverse" "foobar".reverse # => "raboof" And as you can see from this example singleton classes are indeed handled as regular classes: obj = "hello world" class << obj # outputs #> (or similar) p self # outputs Class p self.class # outputs [String, Enumerable, Comparable, Object, Kernel] p self.ancestors attr_accessor :foo end obj.methods(false) # => ["foo", "foo="] That is basically all you need to know about singleton classes. The rest is implementation details. If you really want to give Ruby a look and aren't just doing these evaluations to waste your time / boost your curriculum vitae then that information will help you. If not then you are probably happy about me wasting my time by responding to you. I'm still not sure what your intentions are, but I'd certainly like to believe that you are a honest person, even though you had a bit of trouble with approaching various communities before. It is okay to ask questions about this relatively exotic parts of Ruby, but please do research before asking -- that can mean reading a book that is available online for free, buying a book and reading it in commute time or just trying things out in IRB / a personal set of unit tests.