---
title: "Eigenclass in Ruby"
author: "caiwenhn2008"
date: "2016-08-02T17:50:06Z"
tags: []
categories: ["企业架构"]
slug: "eigenclass-in-ruby"
draft: false
lastmod: "2016-08-02T17:50:06Z"
id: 2315073
url: "https://caerun.iteye.com/blog/2315073"
---

```java

obj = Object.new
def obj.singleton_method 
end

eclass = class << obj
    self
end

puts eclass.class
puts obj.class

class Object
    def eigenclass
        class << self; self; end
    end 
end

puts "abc".eigenclass
puts obj.eigenclass
```