From: Brian Candler Date: 2012-09-18T04:37:06+09:00 Subject: Re: "Anonymous classes or modules", what they are? (Marshaling) Damián M. González wrote in post #1076236: > Brian Candler wrote in post #1076224: > >> It is, but this is a special case. >> >> {"foo" => String, "bar" => Array} >> is serialised as just references to the class named "String" and "Array" >> >> If it worked the way you wanted, then instead of serializing the name it >> would have to serialize everything needed to reconstruct the classes >> "String" and "Array" - including the methods. >> >> So what we gain is the ability to have objects which contain references >> to (named) classes, which is useful, without being able to serialize the >> classes themselves. > > Can you give me a short example? Any object which includes a Class in an instance variable. I dunno: class Factory def initialize(klass) @klass = klass end def make(*args) @klass.new(*args) end end class Foo class <