L
Lionel Thiry
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
# => #<Class:#<Class:#<Class:#<Class:#<Object:0x2aa8348>>>>>
----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?
----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
# => #<Class:#<Class:#<Class:#<Class:#<Object:0x2aa8348>>>>>
----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?