Object.const_get("Array").new
Wolfgang N=E1dasi-Donner
Or more generally,
# from Jim Weirich (based on email correspondence)
def constantize(camel_cased_word)
camel_cased_word.
sub(/^::/,'').
split("::").
inject(Object) { |scope, name| scope.const_get(name) }
end
Also, you can see how ActiveSupport does it for Rails:
# File vendor/rails/activesupport/lib/active_support/inflector.rb, =20
line 245
245: def constantize(camel_cased_word)
246: unless /\A(?::

?([A-Z]\w*(?:::[A-Z]\w*)*)\z/ =3D~ =
camel_cased_word
247: raise NameError, "#{camel_cased_word.inspect} is not a valid =20=
constant name!"
248: end
249:
250: Object.module_eval("::#{$1}", __FILE__, __LINE__)
251: end
-Rob
Rob Biedenharn
http://agileconsultingllc.com
(e-mail address removed)