Hi – long time lurker, first time poster.
While searching for Ruby app configuration best practices, I came
across the config.rb file for WEBrick. In this file, a few hashes are
created as follows:
General = {
:ServerName => Utils::getservername,
:BindAddress => nil, # "0.0.0.0" or "::" or nil
:Port => nil, # users MUST specifiy this!!
:MaxClients => 100, # maximum number of the concurrent
connections
:ServerType => nil, # default: WEBrick::SimpleServer
:Logger => nil, # default: WEBrick::Log.new
:ServerSoftware => "WEBrick/#{WEBrick::VERSION} " +
“(Ruby/#{RUBY_VERSION}/#{RUBY_RELEASE_DATE})”,
:TempDir => ENV[‘TMPDIR’]||ENV[‘TMP’]||ENV[‘TEMP’]||’/
tmp’,
:DoNotListen => false,
:StartCallback => nil,
:StopCallback => nil,
:AcceptCallback => nil,
}
I’m curious as to why the author used symbols here as the hash keys.
Is it for performance reasons? My first inclination was to use
strings in the same way, but after seeing this, I started to wonder
how these symbols are represented internally compared to strings.
Can anyone shed any light on why symbols are used here?
Rick