Dave Burt <dave / burt.id.au> wrote: > Trans: >> >> Yep. Yep. Yep. I've sugegsted it before. But some people don't like >> it, insisting that the ".new" gives some sort of additional clarity. >> Don't know, but like your (our) way better --even wish it were >> built-in. > > Like this? > > def method_missing(sym, *args, &block) > const = Object.const_get(sym) rescue nil > if const.kind_of?(Module) > const.new(*args, &block) > else > raise NoMethodError("undefined method '#{sym}' for > #{self.inspect}") # OK, it is cool. > end > end I'd prefer def method_missing(s, *a, &b) Object.const_get(s).new(*a,&b) end Ruby will throw exceptions for any cases that don't work anyway. Kind regards robert