这个方法是返回任何对象的特征类:
class Object
def eigenclass
class << self; self; end
end
end
字符串示例:
"abc".eigenclass # => #<Class:#<String:0x331df0>>
大批:
[1, 2].eigenclass # => #<Class:#<Array:0x0000000065d218>>
但是使用 Fixnum:
1.eigenclass # => TypeError: can't define singleton
为什么?