title: Swift Dictionary - Update value in setter function
body: <p>My code looks a little like:</p>
  
  <p><strong>Protocol</strong></p>
  
  <pre><code>protocol MyProtocol: class {
      var featureConfigs: [String: Any]? { get set } 
  }
  </code></pre>
  
  <p><strong>Base Class</strong></p>
  
  <pre><code>class MyBaseClass: MyProtocol {
      var featureConfigs: [String : Any]? {
          get {
              return nil
          }
          set {
              self.featureConfigs = newValue
          }
      }
  }
  </code></pre>
  
  <p><strong>Subclass</strong></p>
  
  <pre><code>class MySubclass: MyBaseClass {
      override var featureConfigs: [String : Any]? {
          get {
              return ["feature-specific-configuration":""]
          }
          set {
              self.featureConfigs = newValue
          }
      }
  }
  </code></pre>
  
  <p>I want to be able to update the values stored in <code>featuresConfig</code>. I understand that doing <code>self.featureConfigs = newValue</code> causes an infinite loop but I am unsure of how to update the <code>featuresConfig</code> dictionary correctly. I've read about and tried some things with <code>Subscript</code> but I couldn't get that to work either. Any suggestions?</p>