From: Lionel Thiry Date: 2005-05-15T10:00:29+09:00 Subject: infinite number of singleton_classes Hello! ----8<---- a = Object.new b = class << a class << self class << self class << self # "class << self".times(n) self # "end".times(n) end end end end # => #>>>> ----8<---- How many levels can we reach? It seems there is no limit. I suppose those singleton_class exists only when needed? Otherwise, I really wonder where does ruby hide all those singleton_classes... But, sincerely, is it needed to have the singleton_class of a singleton_class? Isn't it a non-sense? Shouldn't this raise an error? ---8<--- a = Object.new begin b = class << a class << self self end end rescue NewError puts "Sincerely, you don't need the singleton_class of the singleton_class!" end ---8<--- What do you think of it? Isn't it worth an RCR? -- Lionel Thiry Personal website: http://users.skynet.be/lthiry/