title: How do I access Sinatra params using a symbol?
body: <p>In Sinatra, I use params to get the key/value passed through the URL query string. I noticed I can use either a string or a symbol as the key to get the value. So if the URL is:</p>
  
  <pre><code>http://localhost:4567/x?a=1&amp;b=2
  </code></pre>
  
  <p>Then:</p>
  
  <pre><code>params[:a] # =&gt; "1"
  params["a"] # =&gt; "1"
  params.to_s # =&gt; '{"name"=&gt;"x", "a"=&gt;"1", "b"=&gt;"2"}'
  params.class # =&gt; Hash
  </code></pre>
  
  <p>I can tell params is a Hash. But this doesn't seem to be a common behavior of a Hash.</p>
  
  <pre><code>h = {"a" =&gt; "1", "b" =&gt; "2"}
  h["a"] # =&gt; "1"
  h[:a] # =&gt; nil
  </code></pre>
  
  <p>Can someone please explain how this is achieved through Sinatra?</p>