From: Sean O'Halpin Date: 2007-11-06T16:17:18+09:00 Subject: Re: Reading a class-file and calling it at runtime. On 11/5/07, 7stud -- wrote: > >> I have a question about using Object as the receiver in the above line. > >> Is there any specific reason you are using Object? > > > > It's a way of looking up constants in the scope of the top level > > binding (the special Object known as 'main'). > > > > ... so are Module.const_get and Class.const_get: > > class Dog > end > > module Stuff > Greeting = "hello" > end > > > MyConst = 10 > > puts Module.const_get("Dog").new > puts Module.const_get("Stuff")::Greeting > puts Module.const_get("MyConst") > puts > puts Class.const_get("Dog").new > puts Class.const_get("Stuff")::Greeting > puts Class.const_get("MyConst") > > --output:-- > # > hello > 10 > > # > hello > 10 > Hi, This illustrates what I mean: Greeting = "goodbye" class Module Greeting = "hello" end class Class Greeting = "hi!" end puts Module.const_get("Greeting") puts Class.const_get("Greeting") puts Object.const_get("Greeting") puts eval( "Greeting", TOPLEVEL_BINDING ) # for Ara ;) --output-- hello hi! goodbye goodbye Regards, Sean