Last Updated: February 25, 2016
·
1.46K
· Sixeight

Get eigenclass in Ruby

We often need egenclass to write revolutionary code.
You can use Object#singleton_class to get it more easily!

before

(class << obj; self end) #=> #<Class:#<Object:xxx>>

after

obj.singleton_class #=> #<Class:#<Object:xxx>>

(required over Ruby 1.9.2)