Adding the following object to an object should allow me to get a singleton class of any object.
class Object def singleton_class class << self; self; end end end
I had a Powerball class that I created this way
puts Powerball.new.singleton_class puts Powerball.new.singleton_class puts Powerball.singleton_class puts Powerball.singleton_class
He gave me this conclusion
#<Class:#<Powerball:0x007fd333040548>> #<Class:#<Powerball:0x007fd333040408>> #<Class:Powerball> #<Class:Powerball>
So, two instances of the powerball class have unique identifiers, and calling singleton_class directly in the class does not give the identifier of the object.
Questions
Are identifiers unique because each instance has a singleton class?
I understand that self inside the class simply returns the ie Class: Powerball class, but since the class is an object, should it not have an identifier? Is there any way to access this identifier?
source share