From: Bihal Date: 2006-04-11T09:22:51+09:00 Subject: Class Definition inside a method definition? I was under the impression that a class definition could not be inside a method. Quote from Programming Ruby "Method definitions may not contain class, module, or instance method definitions." And yet I've found this source code. def add_accessor(name) methodname = name if self.respond_to?(methodname) methodname = safe_accessor_name(methodname) end sclass = class << self; self; end sclass.__send__(:define_method, methodname, proc { @data[@array.index(name)] }) sclass.__send__(:define_method, methodname + '=', proc { |value| @data[@array.index(name)] = value }) end Are singeltons just special? Bihal -- Posted via http://www.ruby-forum.com/.