From: Ross Bamford Date: 2006-03-17T16:46:13+09:00 Subject: Re: Newbie: Reflection question(?) On Fri, 2006-03-17 at 13:55 +0900, Gaudi Mi wrote: > At runtime I have the name of a class in a string, and I want to call a > method on the class having that name. How do I do that? Here are two possible ways: str = "Array" # => "Array" ary_clz = eval(str) # => Array ary_clz.class # => Class ary_clz.new # => [] ################## ary_clz = Object.const_get(str) # => Array ary_clz.new # => [] -- Ross Bamford - rosco@roscopeco.REMOVE.co.uk