ruby - What does this 'metaclass' method do? -


def metaclass; class << self; self; end; end 

can decipher line me. guess fact it's squeezed 1 doesn't either. having started looking @ ruby 2 days ago, fear might break apart incorrectly.

breaking apart:

def metaclass   class << self     self   end end 

note available built-in method in ruby 1.9.2 (object#singleton_class).

what returning singleton_class/metaclass/eigenclass of object opening same via class << self , returning (self). if confused metaclasses per se, i'd recommend following article:

the ruby object model - structure , semantics


Comments