title: Why do I still need to unwrap Swift dictionary value?
body: <pre><code>class X {
      static let global: [String:String] = [
          "x":"x data",
          "y":"y data",
          "z":"z data"
      ]
  
      func test(){
          let type = "x"
          var data:String = X.global[type]!
      }
  }
  </code></pre>
  
  <p>I'm getting the error: <code>Value of optional type 'String?' not unwrapped</code>.</p>
  
  <p>Why do I need to use <code>!</code> after <code>X.global[type]</code>? I'm not using any optional in my dictionary?</p>
  
  <p><strong>Edited</strong>:</p>
  
  <p>Even if <code>X.global[type]</code> may not exist for the type, force unwrapping will still crash on runtime. A better approach may be:</p>
  
  <pre><code>if let valExist = X.global[type] {
  }
  </code></pre>
  
  <p>but Xcode is giving me the wrong idea by hinting about optional type.</p>