title: How to set a value on computed property
body: <p>I want to set a value to a key in a computed property of type dictionary. I want to do something like this:</p>
  
  <pre><code>class Foo {
      var dict: [String: String] {
          dict["a"] = "b"
      }
  }
  </code></pre>
  
  <p>However that doesn't compile.</p>
  
  <blockquote>
    <p>Cannot assign through subscript: 'dict' is a get-only property</p>
  </blockquote>
  
  <p>I can do something like this but it's a bit verbose:</p>
  
  <pre><code>class Foo {
      var values: [String: String] {
          var tempValues = [String: String]()
          tempValues["a"] = "b"
          return tempValues
      }
  }
  </code></pre>
  
  <p>Is there a better way of doing this? For context, what I want to achieve is having <code>dict</code> by default to be an empty <code>[String: String]()</code> in a base class and when I override the property in a subclass I want to assign values to said dictionary.</p>