From: Brian Candler Date: 2011-04-03T16:55:34+09:00 Subject: Re: Using variables in modules Stefan Salewski wrote in post #990601: > I have a module named Config with a configuration hash, with > predefined colors. I access that hash from other modules. That hash > should have default values, but it should be possible to redefine it. If you want to do this with a constant then you probably want Hash#replace: Config::Colors = {:red => 1, :blue => 2} Config::Colors.replace({:red => 3, :blue => 4}) You'll get no warning because the constant still points to the same object, you've just mutated that object. But as others have said, a class instance variable is probably cleaner. Hash#merge is useful too when you have defaults, so unspecified keys retain their default values: def configure(settings) Config::Colors.replace(Config::Defaults.merge(settings)) end -- Posted via http://www.ruby-forum.com/.