From: Xavier Noria Date: 2010-02-11T18:55:24+09:00 Subject: Re: Newbee question. Runtime classloading On Thu, Feb 11, 2010 at 10:32 AM, Sergey Sheypak wrote: >>Interpreting the file has the side-effect of defining the >> constant, which is in turn a side-effect of the class keyword. > don't get idea with side-effects Ah yes let me explain a bit more. Doing class C end as far as constants and class names is concerned is similar to doing this C = Class.new By the way, top-level constants are stored in Object. Your code works with Kernel because it is mixed in Object and constant lookup goes up, but Object would be the natural place to invoke const_get on. > Something like: > require "parsers/parser_format#{@format_version.gsub(/\./, '_')}" > clz = "ParserFormat#{@format_version.gsub(/\./, '_')}" > parser_impl = Kernel.const_get(clz) > works nicely! That's right.