From: stephen.hill@... (Steve Hill) Date: 2001-08-07T00:00:39+09:00 Subject: [ruby-talk:19219] symbols for global constants Hi I'm getting a bit confused about global constants and class names (using ruby 1.6.2) Suppose I define a class Foo. Then (according to the pickaxe book p253) there is a global constant Foo which references an object of class Foo. This is what enables me to pass Foo as an argument to a function (as given in the example) def factory(klass, *args) klass.new(*args) end factory(String,"Hello") -> "Hello" OK, so this is all well and good. But what happens now if I have a string containing the name of the class I want to create from the factory (the context of my question is parsing a meta file). So, after adding the above example, I tried the following on irb irb > factory(String,"hello") "hello" irb > factory ("String","hello") NameError: undefined method `new' for String:Symbol .... OK, so I didn't expect that to work (although that would have been pushing the "principle of least surprise" too far if it had done :-) I was more surprised that the following did not work irb > factory ("String".intern, "hello") NameError: undefined method `new' for :String:Symbol .... Does anybody have any idea how to achieve this functionality? Best regards Steve