The code below outputs "I am Thing."
class Thing
class << self
def foo
puts "I am #{self}."
end
end
end
Thing.foo
I thought "self" refers to an object of type Thing, but it refers to the class Thing. I have gathered from a previous question (linked in the comments) that this has something to do with the fact that Thing is an instance of Object. Is the block beginning with class << self actually executed in a context where "self" refers to Thing as an instance? What is going on here?