All,

I have a Rails app where I load a YAML file into a class variable (in my 
application.rb file so it's available to all controllers), like so:

  @@config = YAML.load_file("#{RAILS_ROOT}/config/eSimplyConf.yml")

and I created a method to give me back this hash:

  def config
    @@config
  end

However, I notice that when I call config[:key_name], I don't get 
anything, but when I call config['key_name'] I do get the value.  I 
further verified that if I called config[:key_name.to_s], I will get the 
value, thus underscoring the distinction between symbol and string here 
as the type of key_name.

I was under the impression that symbols and strings were interchangeable 
for the purpose of addressing a hash element.  Is this not the case?  Is 
my problem that YAML.load_file generates keys that are strings instead 
of symbols, and of course, I'm using Rails, so that I expect all of my 
hash keys to be symbols :)?

Thanks,
Wes

-- 
Posted via http://www.ruby-forum.com/.