On 4/28/05, Ara.T.Howard <Ara.T.Howard / noaa.gov> 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