From: Christophe Grandsire Date: 2005-10-14T05:10:35+09:00 Subject: Re: instance from class name? En r�ponse � Alexander Lamb : > > However, I didn't find it in the documentation of the Object class. I > started on ruby-lang.org then was brought to rubycentral for the > reference. > Is there another complete reference for ruby 1.8.x? (I am running on > MacOSX 10.4.2). > http://www.ruby-doc.org/ However, the best way is to use ri, the built-in documentation system for Ruby. Just type ri ClassOrModuleName#method to get the documentation for that instance method (without the #method, you get the documentation for the class or module itself, with lists of constants, class or module methods and instance methods, and for class or module methods the syntax is IIRC ri ClassOrModuleName::class_or_module_method). But anyway, const_get isn't defined in Object but in Module. When you call Object.const_get, you are calling an instance method of the object "Object", which is an object of class "Class". Since Class inherits from Module, it inherits its instance method "const_get", which can thus be called on any object of class "Class", i.e. any class. If you don't really understand it, do not fear. It took me a while to get it too. Just remember that in Ruby everything is an object, and that includes classes themselves :) . So you can send methods to them too. -- Christophe Grandsire. http://rainbow.conlang.free.fr You need a straight mind to invent a twisted conlang.