From: Johan Holmberg Date: 2003-09-24T22:29:42+09:00 Subject: Setting "variable" global variable ? Hi ! I wonder if there is any way in Ruby of setting a "variable" global variable at runtime, without using "eval". For example, could the following be done without "eval": def my_set_global_variable(name, val) eval "#{name} = #{val.inspect}" end my_set_global_variable("$foo", [1,2,3]) p $foo # gives [1, 2, 3] I would like to avoid "serializing" the "val" value above (done with the "inspect" call), and assign the original "val" directly instead. For instance variables there is "instance_variable_set", but is there something corresponding for global variables ? /Johan Holmberg