How do I access Sinatra params using a symbol?
问题 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: http://localhost:4567/x?a=1&b=2 Then: params[:a] # => "1" params["a"] # => "1" params.to_s # => '{"name"=>"x", "a"=>"1", "b"=>"2"}' params.class # => Hash I can tell params is a Hash. But this doesn't seem to be a common behavior of a Hash. h = {"a" => "1", "b" => "2"} h["a"] # => "1" h[:a] # => nil Can someone please