From: Mark Hubbart Date: 2005-04-30T16:35:16+09:00 Subject: instantiating metaclasses, sorta [Was: determining when inside 'class << self'] On 4/28/05, Ara.T.Howard wrote: > > i like a method like this > > def inside_metaclass? > # to be implemented > end While experimenting with this, I discovered something interesting: it is possible to instantiate a metaclass. By duping a metaclass, you regain the ability to instantiate it, apparently without losing any functionality. name = "Jack Smith" def name.reverse split.reverse.join ", " end name.reverse #==> "Smith, Jack" # dup name's metaclass nameclass = class << name; self; end.dup name2 = nameclass.new "John Doe" name2.reverse #==> "Doe, John" Any thoughts? Am I strange for finding this a bit surprising? cheers, Mark