I'm working on this tutorial here: http://rubymonk.com/learning/books/4-ruby-primer-ascent/chapters/39-ruby-s-object-model/lessons/131-singleton-methods-and-metaclasses
The lesson is on classes/metaclasses, but they are using a syntax that I'm not familiar with. Please see the use of << below
class Object
def metaclass
class << self
self
end
end
end
a=Object.new
p a.metaclass.new
I know def metaclass
is a method, but what is meant by class << self
? It has a corresponding end
block, but I'm still very unclear what this is exactly doing
(Note: The point of the above exercise is just showing that you cannot instantiate a metaclass -- which I understand, I'm just having trouble wrapping my head around that << operator in this context.
Thanks!